feat(keycloak) Optional Keycloak integration via OpenId Connect (OIDC) for Identity and Access Management (#227)
This commit is contained in:
1 parent
03d0798459
commit
33755f7b8b
25 files changed
+294
-11
No files matched your search
@@ -0,0 +1,51 @@
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import { ServiceConfiguration } from 'meteor/service-configuration';
|
||||
import { Accounts } from "meteor/accounts-base";
|
||||
|
||||
console.log('Keycloak settings were found! Enabling Keycloak integration.');
|
||||
|
||||
ServiceConfiguration.configurations.upsert(
|
||||
{ service: 'keycloak' },
|
||||
{
|
||||
$set: {
|
||||
"realm": Meteor.settings.public.custom.keycloak.realmName,
|
||||
"auth-server-url": Meteor.settings.public.custom.keycloak.authServerUrl,
|
||||
"auth_redirect_uri": Meteor.settings.keycloak.authRedirectUri,
|
||||
"ssl-required": Meteor.settings.keycloak.sslRequired,
|
||||
"resource": Meteor.settings.keycloak.clientId,
|
||||
"client_id": Meteor.settings.keycloak.clientId,
|
||||
"loginStyle": Meteor.settings.keycloak.loginStyle,
|
||||
"secret": Meteor.settings.keycloak.clientSecret,
|
||||
"realm-public-key": Meteor.settings.keycloak.realmPublicKey,
|
||||
"public-client": false,
|
||||
"use-resource-role-mappings": false,
|
||||
"bearer-only": false,
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Meteor.publish('user.services.keycloak', function() {
|
||||
const userId = this.userId;
|
||||
if (!userId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Meteor.users.find(userId, {
|
||||
fields: {
|
||||
'services.keycloak': 1
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Accounts.onLogout(({ user }) => {
|
||||
if (!user) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Erase any Keycloak token that exists
|
||||
Meteor.users.update(user._id, {
|
||||
$unset: {
|
||||
'services.keycloak': 1
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user