File tree Expand file tree Collapse file tree 4 files changed +14
-6
lines changed
Filter options
Expand file tree Collapse file tree 4 files changed +14
-6
lines changed
Original file line number Diff line number Diff line change @@ -101,7 +101,11 @@ public function getUserBadgeFrom(string $accessToken): UserBadge
101
101
}
102
102
103
103
// UserLoader argument can be overridden by a UserProvider on AccessTokenAuthenticator::authenticate
104
- return new UserBadge ($ claims [$ this ->claim ], new FallbackUserLoader (fn () => $ this ->createUser ($ claims )), $ claims );
104
+ return new UserBadge ($ claims [$ this ->claim ], new FallbackUserLoader (function () use ($ claims ) {
105
+ $ claims ['user_identifier ' ] = $ claims [$ this ->claim ];
106
+
107
+ return $ this ->createUser ($ claims );
108
+ }), $ claims );
105
109
} catch (\Exception $ e ) {
106
110
$ this ->logger ?->error('An error occurred while decoding and validating the token. ' , [
107
111
'error ' => $ e ->getMessage (),
Original file line number Diff line number Diff line change @@ -47,7 +47,11 @@ public function getUserBadgeFrom(string $accessToken): UserBadge
47
47
}
48
48
49
49
// UserLoader argument can be overridden by a UserProvider on AccessTokenAuthenticator::authenticate
50
- return new UserBadge ($ claims [$ this ->claim ], new FallbackUserLoader (fn () => $ this ->createUser ($ claims )), $ claims );
50
+ return new UserBadge ($ claims [$ this ->claim ], new FallbackUserLoader (function () use ($ claims ) {
51
+ $ claims ['user_identifier ' ] = $ claims [$ this ->claim ];
52
+
53
+ return $ this ->createUser ($ claims );
54
+ }), $ claims );
51
55
} catch (\Exception $ e ) {
52
56
$ this ->logger ?->error('An error occurred on OIDC server. ' , [
53
57
'error ' => $ e ->getMessage (),
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ public function testGetsUserIdentifierFromSignedToken(string $claim, string $exp
48
48
'email ' => 'foo@example.com ' ,
49
49
];
50
50
$ token = $ this ->buildJWS (json_encode ($ claims ));
51
- $ expectedUser = new OidcUser (...$ claims );
51
+ $ expectedUser = new OidcUser (...$ claims, userIdentifier: $ claims [ $ claim ] );
52
52
53
53
$ loggerMock = $ this ->createMock (LoggerInterface::class);
54
54
$ loggerMock ->expects ($ this ->never ())->method ('error ' );
@@ -67,7 +67,7 @@ public function testGetsUserIdentifierFromSignedToken(string $claim, string $exp
67
67
$ this ->assertInstanceOf (OidcUser::class, $ actualUser );
68
68
$ this ->assertEquals ($ expectedUser , $ actualUser );
69
69
$ this ->assertEquals ($ claims , $ userBadge ->getAttributes ());
70
- $ this ->assertEquals ($ claims [' sub ' ], $ actualUser ->getUserIdentifier ());
70
+ $ this ->assertEquals ($ claims [$ claim ], $ actualUser ->getUserIdentifier ());
71
71
}
72
72
73
73
public static function getClaims (): iterable
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ public function testGetsUserIdentifierFromOidcServerResponse(string $claim, stri
33
33
'sub ' => 'e21bf182-1538-406e-8ccb-e25a17aba39f ' ,
34
34
'email ' => 'foo@example.com ' ,
35
35
];
36
- $ expectedUser = new OidcUser (...$ claims );
36
+ $ expectedUser = new OidcUser (...$ claims, userIdentifier: $ claims [ $ claim ] );
37
37
38
38
$ responseMock = $ this ->createMock (ResponseInterface::class);
39
39
$ responseMock ->expects ($ this ->once ())
@@ -52,7 +52,7 @@ public function testGetsUserIdentifierFromOidcServerResponse(string $claim, stri
52
52
$ this ->assertInstanceOf (OidcUser::class, $ actualUser );
53
53
$ this ->assertEquals ($ expectedUser , $ actualUser );
54
54
$ this ->assertEquals ($ claims , $ userBadge ->getAttributes ());
55
- $ this ->assertEquals ($ claims [' sub ' ], $ actualUser ->getUserIdentifier ());
55
+ $ this ->assertEquals ($ claims [$ claim ], $ actualUser ->getUserIdentifier ());
56
56
}
57
57
58
58
public static function getClaims (): iterable
You can’t perform that action at this time.
0 commit comments