Skip to content

Commit 2c68ecf

Browse files
authored
Fix KeyNotFoundException in OIDCHandler.AuthenticateCoreAsync #315 (#316)
1 parent ae59e4b commit 2c68ecf

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Microsoft.Owin.Security.OpenIdConnect/OpenidConnectAuthenticationHandler.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,8 @@ protected override async Task<AuthenticationTicket> AuthenticateCoreAsync()
384384
ClientSecret = Options.ClientSecret,
385385
Code = authorizationResponse.Code,
386386
GrantType = OpenIdConnectGrantTypes.AuthorizationCode,
387-
RedirectUri = properties.Dictionary[OpenIdConnectAuthenticationDefaults.RedirectUriUsedForCodeKey]
387+
RedirectUri = properties.Dictionary.ContainsKey(OpenIdConnectAuthenticationDefaults.RedirectUriUsedForCodeKey) ?
388+
properties.Dictionary[OpenIdConnectAuthenticationDefaults.RedirectUriUsedForCodeKey] : string.Empty,
388389
};
389390

390391
var authorizationCodeReceivedNotification = new AuthorizationCodeReceivedNotification(Context, Options)
@@ -393,8 +394,7 @@ protected override async Task<AuthenticationTicket> AuthenticateCoreAsync()
393394
Code = authorizationResponse.Code,
394395
JwtSecurityToken = jwt,
395396
ProtocolMessage = authorizationResponse,
396-
RedirectUri = properties.Dictionary.ContainsKey(OpenIdConnectAuthenticationDefaults.RedirectUriUsedForCodeKey) ?
397-
properties.Dictionary[OpenIdConnectAuthenticationDefaults.RedirectUriUsedForCodeKey] : string.Empty,
397+
RedirectUri = tokenEndpointRequest.RedirectUri,
398398
TokenEndpointRequest = tokenEndpointRequest
399399
};
400400
await Options.Notifications.AuthorizationCodeReceived(authorizationCodeReceivedNotification);

0 commit comments

Comments
 (0)