This repository was archived by the owner on Sep 9, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed
Sentinel.OAuth.Core/Models
Sentinel.OAuth/Providers/OAuth Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -14,8 +14,9 @@ public class SentinelAuthorizationServerEvents
1414 public Func < TokenIssuedEventArgs , Task > TokenIssued ;
1515
1616 /// <summary>
17- /// Activated when the user is logged in and the principal is created. Use this event to add any
18- /// custom claims to the user before the token is created.
17+ /// Activated when the user is logged in (either via a username and password, or a refresh token)
18+ /// and the principal is created. Use this event to add any custom claims to the user before the
19+ /// token is created.
1920 /// </summary>
2021 public Func < PrincipalCreatedEventArgs , Task > PrincipalCreated ;
2122
Original file line number Diff line number Diff line change @@ -345,7 +345,19 @@ public override async Task GrantRefreshToken(OAuthGrantRefreshTokenContext conte
345345 {
346346 this . options . Logger . Debug ( "Authenticating refresh token flow" ) ;
347347
348- context . Validated ( ) ;
348+ var user = new SentinelPrincipal ( context . Ticket . Identity ) ;
349+
350+ // Activate event if subscribed to
351+ if ( this . options . Events . PrincipalCreated != null )
352+ {
353+ var args = new PrincipalCreatedEventArgs ( user , context ) ;
354+
355+ await this . options . Events . PrincipalCreated ( args ) ;
356+
357+ user = new SentinelPrincipal ( args . Principal ) ;
358+ }
359+
360+ context . Validated ( user . Identity . AsClaimsIdentity ( ) ) ;
349361 }
350362
351363 /// <summary>Called before the TokenEndpoint redirects its response to the caller.</summary>
You can’t perform that action at this time.
0 commit comments