#506 Update to Rc1 IdentityModel, update ValidateUserInfoEndpointResponse.
This commit is contained in:
parent
b5712ef176
commit
f588677bb4
|
|
@ -21,6 +21,8 @@ namespace OpenIdConnectSample
|
|||
{
|
||||
loggerfactory.AddConsole(LogLevel.Information);
|
||||
|
||||
app.UseIISPlatformHandler();
|
||||
|
||||
app.UseCookieAuthentication(options =>
|
||||
{
|
||||
options.AutomaticAuthenticate = true;
|
||||
|
|
@ -31,8 +33,9 @@ namespace OpenIdConnectSample
|
|||
options.ClientId = "63a87a83-64b9-4ac1-b2c5-092126f8474f";
|
||||
options.ClientSecret = "Yse2iP7tO1Azq0iDajNisMaTSnIDv+FXmAsFuXr+Cy8="; // for code flow
|
||||
options.Authority = "https://login.windows.net/tratcheroutlook.onmicrosoft.com";
|
||||
options.RedirectUri = "http://localhost:42023";
|
||||
options.RedirectUri = "http://localhost:42023/signin-oidc";
|
||||
options.ResponseType = OpenIdConnectResponseTypes.Code;
|
||||
options.GetClaimsFromUserInfoEndpoint = true;
|
||||
});
|
||||
|
||||
app.Run(async context =>
|
||||
|
|
|
|||
|
|
@ -2,19 +2,19 @@
|
|||
"dependencies": {
|
||||
"Microsoft.AspNet.Authentication.Cookies": "1.0.0-*",
|
||||
"Microsoft.AspNet.Authentication.OpenIdConnect": "1.0.0-*",
|
||||
"Microsoft.AspNet.DataProtection": "1.0.0-*",
|
||||
"Microsoft.AspNet.Server.IIS": "1.0.0-*",
|
||||
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-*",
|
||||
"Microsoft.AspNet.Server.Kestrel": "1.0.0-*",
|
||||
"Microsoft.AspNet.Server.WebListener": "1.0.0-*",
|
||||
"Microsoft.Extensions.Logging.Console": "1.0.0-*",
|
||||
"Microsoft.AspNet.Server.Kestrel": "1.0.0-*"
|
||||
"Microsoft.Extensions.Logging.Console": "1.0.0-*"
|
||||
},
|
||||
"frameworks": {
|
||||
"dnx451": { },
|
||||
"dnxcore50": { }
|
||||
},
|
||||
"commands": {
|
||||
"web": "Microsoft.AspNet.Hosting server=Microsoft.AspNet.Server.WebListener server.urls=http://localhost:42023",
|
||||
"kestrel": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel --server.urls http://localhost:42023"
|
||||
"web": "Microsoft.AspNet.Server.Kestrel",
|
||||
"kestrel": "Microsoft.AspNet.Server.Kestrel --server.urls http://localhost:42023",
|
||||
"weblistener": "Microsoft.AspNet.Server.WebListener --server.urls http://localhost:42023"
|
||||
},
|
||||
"webroot": "wwwroot"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<system.webServer>
|
||||
<handlers>
|
||||
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
|
||||
</handlers>
|
||||
<httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" forwardWindowsAuthToken="false" startupTimeLimit="3600" />
|
||||
</system.webServer>
|
||||
</configuration>
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"Microsoft.AspNet.Authentication": "1.0.0-*",
|
||||
"Microsoft.IdentityModel.Protocols.OpenIdConnect": "2.0.0-beta8-*"
|
||||
"Microsoft.IdentityModel.Protocols.OpenIdConnect": "2.0.0-rc1-*"
|
||||
},
|
||||
"frameworks": {
|
||||
"dnx451": {
|
||||
|
|
|
|||
|
|
@ -659,8 +659,21 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect
|
|||
var responseMessage = await Backchannel.SendAsync(requestMessage);
|
||||
responseMessage.EnsureSuccessStatusCode();
|
||||
var userInfoResponse = await responseMessage.Content.ReadAsStringAsync();
|
||||
var userInfoEndpointJwt = new JwtSecurityToken(userInfoResponse);
|
||||
var user = JObject.Parse(userInfoResponse);
|
||||
JObject user;
|
||||
var contentType = responseMessage.Content.Headers.ContentType;
|
||||
if (contentType.MediaType.Equals("application/json", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
user = JObject.Parse(userInfoResponse);
|
||||
}
|
||||
else if (contentType.MediaType.Equals("application/jwt", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var userInfoEndpointJwt = new JwtSecurityToken(userInfoResponse);
|
||||
user = JObject.FromObject(userInfoEndpointJwt.Payload);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotSupportedException("Unknown response type: " + contentType.MediaType);
|
||||
}
|
||||
|
||||
var userInformationReceivedContext = await RunUserInformationReceivedEventAsync(ticket, message, user);
|
||||
if (userInformationReceivedContext.HandledResponse)
|
||||
|
|
@ -676,7 +689,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect
|
|||
|
||||
Options.ProtocolValidator.ValidateUserInfoResponse(new OpenIdConnectProtocolValidationContext()
|
||||
{
|
||||
UserInfoEndpointResponse = userInfoEndpointJwt,
|
||||
UserInfoEndpointResponse = userInfoResponse,
|
||||
ValidatedIdToken = jwt,
|
||||
});
|
||||
|
||||
|
|
@ -710,7 +723,7 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect
|
|||
identity.AddClaim(new Claim(pair.Key, claimValue, ClaimValueTypes.String, Options.ClaimsIssuer));
|
||||
}
|
||||
|
||||
return new AuthenticationTicket(new ClaimsPrincipal(identity), ticket.Properties, ticket.AuthenticationScheme);
|
||||
return ticket;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"Microsoft.AspNet.Authentication": "1.0.0-*",
|
||||
"Microsoft.IdentityModel.Protocols.OpenIdConnect": "2.0.0-beta8-*"
|
||||
"Microsoft.IdentityModel.Protocols.OpenIdConnect": "2.0.0-rc1-*"
|
||||
},
|
||||
"frameworks": {
|
||||
"dnx451": {
|
||||
|
|
|
|||
Loading…
Reference in New Issue