@@ -31,12 +31,14 @@ module.exports = (SSOUtils) => {
31
31
auth : ( Env , cfg , cb ) => {
32
32
getClient ( cfg , ( err , client ) => {
33
33
if ( err ) { return void cb ( 'E_OIDC_CONNECT' ) ; }
34
+ let username_scope = cfg . username_scope || 'profile' ;
35
+ let email_scope = cfg . email_scope || 'email' ; // This is not yet used
34
36
35
37
const generators = OID . generators ;
36
38
const code_verifier = generators . codeVerifier ( ) ;
37
39
const code_challenge = generators . codeChallenge ( code_verifier ) ;
38
40
const url = client . authorizationUrl ( {
39
- scope : ' openid email profile' ,
41
+ scope : ` openid ${ username_scope } ${ email_scope } ` ,
40
42
resource : opts . callbackURL ,
41
43
access_type : 'offline' ,
42
44
code_challenge,
@@ -52,11 +54,15 @@ module.exports = (SSOUtils) => {
52
54
53
55
const params = client . callbackParams ( url ) ;
54
56
delete params . state ;
57
+
58
+ let username_claim = cfg . username_claim || 'name' ;
59
+ let email_claim = cfg . email_claim || 'email' ; // This is not yet used
60
+
55
61
client . callback ( opts . callbackURL , params , { code_verifier : token } )
56
62
. then ( ( tokenSet ) => {
57
63
let j = tokenSet ;
58
64
let c = tokenSet . claims ( ) ;
59
- let name = c . name ;
65
+ let name = c [ username_claim ] ;
60
66
const end = ( ) => {
61
67
cb ( void 0 , {
62
68
id : c . sub ,
0 commit comments