startup.cs 파일 코드 세부 정보에 따라 azure b2c에 대해 asp.net mvc 앱을 인증하고 있습니다.
public void ConfigureAuth(IAppBuilder app)
{
IdentityModelEventSource.ShowPII = true;
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions());
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
// Generate the metadata address using the tenant and policy information
MetadataAddress = String.Format(Globals.WellKnownMetadata, Globals.Tenant, Globals.DefaultPolicy),
// These are standard OpenID Connect parameters, with values pulled from web.config
ClientId = Globals.ClientId,
RedirectUri = Globals.RedirectUri,
PostLogoutRedirectUri = Globals.RedirectUri,
// Specify the callbacks for each type of notifications
Notifications = new OpenIdConnectAuthenticationNotifications
{
RedirectToIdentityProvider = OnRedirectToIdentityProvider,
AuthorizationCodeReceived = OnAuthorizationCodeReceived,
AuthenticationFailed = OnAuthenticationFailed,
},
// Specify the claim type that specifies the Name property.
TokenValidationParameters = new TokenValidationParameters
{
NameClaimType = "name",
ValidateIssuer = false
},
// Specify the scope by appending all of the scopes requested into one string (separated by a blank space)
Scope = $"openid profile offline_access {Globals.ReadTasksScope} {Globals.WriteTasksScope}"
});
}
사용자 지정 정책을 사용할 때 아래 오류가 발생합니다. IDX10501 : 서명 유효성 검사에 실패했습니다. 키를 일치시킬 수 없음 : 어린이 : 'gL ****************'. 발견 된 예외 : ''. 토큰 : typ ":"JWT ","alg ":"RS256 ","kid ":"gL **************** "}. {"exp ": 1599625561," nbf ": 1599621961,"ver ":"1.0 ","iss ": ......................}
이 키와 토큰을 https://jwt.ms 에서 얻은 것과 정확히 동일하게 확인했습니다 . 기본 제공 정책을 사용하면 예상대로 작동하는 경우 사용자 지정 정책을 사용하는 동안 오류가 발생합니다.
여기에 누락 된 것이 무엇입니까?
감사.
확인한대로 사용자 지정 정책의 서명 키 및 암호화 키에 문제가있었습니다. 둘 다 올바르게 생성 하면 문제가 해결되었습니다.
서명 키 만들기
- 정책 키를 선택한 다음 추가를 선택합니다.
- 옵션에서 생성을 선택합니다.
- 이름에 TokenSigningKeyContainer를 입력합니다. 접두사 B2C_1A_가 자동으로 추가 될 수 있습니다.
- 키 유형으로 RSA를 선택합니다.
- 키 사용에 대해 서명을 선택하십시오.
- 만들기를 선택합니다.
암호화 키 만들기
- 정책 키를 선택한 다음 추가를 선택합니다.
- 옵션에서 생성을 선택합니다.
- 이름에 TokenEncryptionKeyContainer를 입력합니다. 접두사 B2C_1A_가 자동으로 추가 될 수 있습니다.
- 키 유형으로 RSA를 선택합니다.
- 키 사용에 대해 암호화를 선택합니다.
- 만들기를 선택합니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다