-
Notifications
You must be signed in to change notification settings - Fork 2
/
keycloak.js
30 lines (28 loc) · 1.07 KB
/
keycloak.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Accounts.oauth.registerService('keycloak');
if (Meteor.isClient) {
const loginWithKeycloak = function(options, callback) {
// support a callback without options
if (! callback && typeof options === "function") {
callback = options;
options = null;
}
var credentialRequestCompleteCallback = Accounts.oauth.credentialRequestCompleteHandler(callback);
Keycloak.requestCredential(options, credentialRequestCompleteCallback);
};
Accounts.registerClientLoginFunction('keycloak', loginWithKeycloak);
Meteor.loginWithKeycloak = function () {
return Accounts.applyLoginFunction('keycloak', arguments);
};
} else {
Accounts.addAutopublishFields({
// publish all fields including access token, which can legitimately
// be used from the client (if transmitted over ssl or on
// localhost).
forLoggedInUser: ['services.keycloak'],
forOtherUsers: [
'services.keycloak.name', 'services.keycloak.given_name',
'services.keycloak.family_name', 'services.keycloak.preferred_username',
'services.keycloak.picture'
]
});
}