0
IdentityServer3을 설치했으며 aspnetIdentity 데이터베이스에 저장된 사용자 이름과 암호를 사용하여 성공적으로 인증 할 수 있습니다. 문제는 클라이언트 MVC 응용 프로그램 측면에 있습니다. ID 서버 응용 프로그램에서 인증 코드를 받으면 다음 예외가 throw됩니다.aspnet 핵심 클라이언트가 설치된 IdentityServer3
내요청을 처리하는 동안 처리되지 않은 예외가 발생했습니다.
경우 InvalidOperationException : 없음 인증 핸들러가 체계를 처리 에 구성되지 않은 : 쿠키
Startup.cs
은 다음과 같습니다 : 당신이 당신의 구성에서 대소 문자 구분 문제를 가지고있는 것처럼
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
app.UseBrowserLink();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseApplicationInsightsExceptionTelemetry();
app.UseStaticFiles();
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();
app.UseCookieAuthentication(new CookieAuthenticationOptions()
{
AuthenticationScheme = "Cookies",
AutomaticAuthenticate = true,
AutomaticChallenge = true
});
var secret = Configuration["Secrets:SharedSecret"];//.ToSha256();
var connectOptions = new OpenIdConnectOptions
{
AutomaticChallenge = true,
AutomaticAuthenticate=true,
AuthenticationScheme = "oidc",
SignInScheme = "cookies",
Authority = "http://localhost:4889/core/",
PostLogoutRedirectUri = "http://localhost:5059/",
CallbackPath = "/home/index",
ClientSecret = secret,
RequireHttpsMetadata = false,
ClientId = "communicator",
DisplayName = "Communicator",
ResponseType = "code id_token",
GetClaimsFromUserInfoEndpoint = true,
SaveTokens = true,
Events = new OpenIdConnectEvents()
{
OnUserInformationReceived = async y =>
{
var identity = y.Ticket.Principal.Identity as ClaimsIdentity;
var subject = identity.Claims.FirstOrDefault(z => z.Type == "sub");
// Do something with subject like lookup in local users DB.
var newIdentity = new ClaimsIdentity(y.Ticket.AuthenticationScheme,"given_name","role");
// Do some stuff to `newIdentity` like adding claims.
// Create a new ticket with `newIdentity`.
//Ticket = new Ticket(new ClaimsPrincipal(newIdentity),
//y.Ticket.Properties,
//y.Ticket.AuthenticationScheme);
await Task.FromResult(0);
},
OnAuthorizationCodeReceived= async c=>
{
var identity = c.Ticket.Principal.Identity as ClaimsIdentity;
var subject = identity.Claims.FirstOrDefault(z => z.Type == "sub");
await Task.FromResult(0);
}
}
};
connectOptions.Scope.Clear();
connectOptions.Scope.Add("openid");
connectOptions.Scope.Add("profile");
connectOptions.Scope.Add("roles");
connectOptions.Scope.Add("smsapi");
app.UseOpenIdConnectAuthentication(connectOptions);
'AuthenticationScheme'은'CookieAuthenticationOptions'에서 대소 문자를 구분합니까? –