@@ -219,6 +219,10 @@ public function settingsController_topcoder_create($sender) {
219
219
'Plugins.Topcoder.SSO.CookieName ' => ['Control ' => 'TextBox ' , 'Default ' => '' , 'Description ' => 'Topcoder Cookie Name ' ],
220
220
'Plugins.Topcoder.SSO.TopcoderHS256.UsernameClaim ' => ['Control ' => 'TextBox ' , 'Default ' => '' , 'Description ' => 'Topcoder Username Claim for HS256 JWT ' ],
221
221
'Plugins.Topcoder.SSO.TopcoderRS256.UsernameClaim ' => ['Control ' => 'TextBox ' , 'Default ' => '' , 'Description ' => 'Topcoder Username Claim for RS256 JWT ' ],
222
+ 'Plugins.Topcoder.SSO.TopcoderHS256.UserIDClaim ' => ['Control ' => 'TextBox ' , 'Default ' => '' , 'Description ' => 'Topcoder User ID Claim for HS256 JWT ' ],
223
+ 'Plugins.Topcoder.SSO.TopcoderRS256.UserIDClaim ' => ['Control ' => 'TextBox ' , 'Default ' => '' , 'Description ' => 'Topcoder User ID Claim for RS256 JWT ' ],
224
+ 'Plugins.Topcoder.SSO.TopcoderHS256.PhotoUrlClaim ' => ['Control ' => 'TextBox ' , 'Default ' => '' , 'Description ' => 'Topcoder Photo URL Claim for HS256 JWT ' ],
225
+ 'Plugins.Topcoder.SSO.TopcoderRS256.PhotoUrlClaim ' => ['Control ' => 'TextBox ' , 'Default ' => '' , 'Description ' => 'Topcoder Photo URL Claim for RS256 JWT ' ],
222
226
]);
223
227
224
228
$ cf ->renderAll ();
@@ -373,16 +377,22 @@ public function gdn_auth_startAuthenticator_handler() {
373
377
374
378
$ AUTH0_AUDIENCE = null ;
375
379
$ USERNAME_CLAIM = null ;
380
+ $ PHOTOURL_CLAIM = null ;
381
+ $ USERID_CLAIM = null ;
376
382
if ($ decodedToken ->getHeader ('alg ' ) === 'RS256 ' ) {
377
383
$ AUTH0_AUDIENCE = c ('Plugins.Topcoder.SSO.TopcoderRS256.ID ' );
378
384
$ USERNAME_CLAIM = c ('Plugins.Topcoder.SSO.TopcoderRS256.UsernameClaim ' );
385
+ $ USERID_CLAIM = c ('Plugins.Topcoder.SSO.TopcoderRS256.UserIDClaim ' );
386
+ $ PHOTOURL_CLAIM = c ('Plugins.Topcoder.SSO.TopcoderRS256.PhotoUrlClaim ' );
379
387
$ jwksUri = $ issuer . '.well-known/jwks.json ' ;
380
388
$ jwksHttpOptions = ['base_uri ' => $ jwksUri ];
381
389
$ jwksFetcher = new JWKFetcher ($ this ->cacheHandler , $ jwksHttpOptions );
382
390
$ signatureVerifier = new AsymmetricVerifier ($ jwksFetcher );
383
391
384
392
} else if ($ decodedToken ->getHeader ('alg ' ) === 'HS256 ' ) {
385
393
$ USERNAME_CLAIM = c ('Plugins.Topcoder.SSO.TopcoderHS256.UsernameClaim ' );
394
+ $ USERID_CLAIM = c ('Plugins.Topcoder.SSO.TopcoderHS256.UserIDClaim ' );
395
+ $ PHOTOURL_CLAIM = c ('Plugins.Topcoder.SSO.TopcoderHS256.PhotoUrlClaim ' );
386
396
$ AUTH0_AUDIENCE = c ('Plugins.Topcoder.SSO.TopcoderHS256.ID ' );
387
397
$ CLIENT_H256SECRET = c ('Plugins.Topcoder.SSO.TopcoderHS256.Secret ' );
388
398
$ signatureVerifier = new SymmetricVerifier ($ CLIENT_H256SECRET );
@@ -450,8 +460,11 @@ public function gdn_auth_startAuthenticator_handler() {
450
460
$ this ->checkTopcoderRoles ($ topcoderRoles );
451
461
452
462
$ topcoderUserName = $ decodedToken ->getClaim ($ USERNAME_CLAIM );
463
+ $ topcoderPhotoUrl = $ decodedToken ->getClaim ($ PHOTOURL_CLAIM );
464
+ $ topcoderUserID = $ decodedToken ->getClaim ($ USERID_CLAIM );
465
+
453
466
if ($ topcoderUserName ) {
454
- self ::log ('Trying to signIn ... ' , ['username ' => $ topcoderUserName ]);
467
+ self ::log ('Trying to signIn ... ' , ['username ' => $ topcoderUserName, ' topcoderId ' => $ topcoderUserID , ' photoUrl ' => $ topcoderPhotoUrl , ]);
455
468
456
469
$ userModel = new UserModel ();
457
470
$ user = $ userModel ->getByUsername ($ topcoderUserName , false );
@@ -515,6 +528,10 @@ public function gdn_auth_startAuthenticator_handler() {
515
528
self ::log ('The session could not be started. ' , []);
516
529
throw new ClientException ('The session could not be started. ' , 401 );
517
530
}
531
+
532
+ Gdn::userModel ()->saveAttribute (
533
+ Gdn::session ()->UserID ,
534
+ ['TopcoderUserID ' => $ topcoderUserID , 'TopcoderPhotoUrl ' => $ topcoderPhotoUrl ]);
518
535
} else {
519
536
self ::log ('Go with the next Vanilla Authenticator ' , []);
520
537
}
0 commit comments