나는의 OAuth 2.0 인증 서버 샘플 코드 다음 http://www.asp.net/aspnet/overview/owin-and-katana/owin-oauth-20-authorization-serverOWIN 쿠키 미들웨어를 수동 인증 모드로 설정하는 올바른 방법은 무엇입니까?
뿐만 아니라 너겟 패키지에서 찾고있다 Microsoft.aspnet.identity.samples 패키지 (설치 패키지 Microsoft.aspnet.identity.samples - 전)
그리고 수동적 인 쿠키와 활성 쿠키의 미들웨어가 작동하는 방식을 고민하고 있습니다.
인증 서버 예제에서 "Application"쿠키는 수동으로 설정됩니다. ID 샘플에서 "ApplicationCookie"가 활성화되어 있습니다.
이 속성에 대해 읽으면 패시브 미들웨어가 일치하는 AuthenticationType에 의해 요청 될 때만 트리거된다는 것을 설명합니다. 나는 Microsoft.aspnet.identity.samples에서 startup.auth.cs 파일을 편집하고 수동으로 응용 프로그램 쿠키를 설정하면
후 로그인이 검증 보이지만, 나를 기록하지 않습니다.
을 (사용자 DefaultAuthenticationTypes.ApplicationCookie) CreateIdentityAsync 을 : 코드에 더 깊이 파고, 나는 아래로 SignInHelper.SignInAsync
이 메소드의 호출에 계정 컨트롤러 종기가 전화를 인 사용자로부터 claimsidentity를 얻을 것을 볼
나는 분명히 이해하지 못하고 있습니다. 왜냐하면 내가 읽었고 말할 수있는 것에서부터 전자 쿠키는 Claim과 동일한 AuthenticationType을 가지고 있지만 Authentication.SignIn을 호출하면 쿠키가 설정되지 않은 것처럼 보이며 등록 및 로그인 옵션이있는 기본 페이지로 돌아갑니다.
이 문제를 중복 새로운 프로젝트 빈 asp.net 응용 프로그램을 시작하려면 다음 신원 샘플 패키지를 설치 한 다음에 startup.auth.cs의 app.useCookieAuthentication을 변경app.UseCookieAuthentication(new CookieAuthenticationOptions {
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
AuthenticationMode = Microsoft.Owin.Security.AuthenticationMode.Passive,
LoginPath = new PathString("/Account/Login"),
Provider = new CookieAuthenticationProvider {
// Enables the application to validate the security stamp when the user logs in.
// This is a security feature which is used when you change a password or add an external login to your account.
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
validateInterval: TimeSpan.FromMinutes(30),
regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
}
});
나는 변화 시도 startup.auth.cs에 쿠키 이름을 추가하고 아무런 소용이 없다고 주장하는 코드에 "사용자 정의"이름을 추가하십시오.
나는 연구를 계속할 예정이지만, 그동안 커뮤니티에 연락 할 것이라고 생각했습니다.
안녕하세요. William, 고마워요. 필자는 Brock Allen의 블로그와 게시물을 몇 차례 읽었으며 본질적으로이 말을 알아 내려고 노력하고 있습니다. "수동적 미들웨어는 요청이있을 때만 요청을 검사합니다." AuthenticationType, IE를 지정하는 것입니다. 인증 유형을 생성 할 때 인증 유형을 생성해야합니다. 그러나 이렇게하면 모든 인증 코드가 성공하지만 쿠키가 설정되지 않습니다. 활성 미들웨어가 자동으로 수행해야하는 작업을 수동으로 수행해야하는지 파악하려고합니다. – Steve
위 코드에 추가하려면 AuthenticationMode = Microsoft.Owin.Security.AuthenticationMode.Active에 대한 AuthenticationMode = Microsoft.Owin.Security.AuthenticationMode.Passive를 제외한 모든 항목이 동일한 방식으로 작동한다는 것을 알고 있습니다. 활성 상태에서 쿠키는 인증 후 설정되고 로그인됩니다. 수동태는 모두 작동하지만 쿠키는 설정되지 않습니다. 액티브 미들웨어처럼 개발자가 쿠키 생성을 트리거하기 위해해야 할 일을 결정하려고합니다. – Steve
클레임 ID로 SignIn을 호출하면 쿠키 생성이 트리거되며 활성/수동 모드는 쿠키 생성에 영향을 미치지 않아야합니다. 전혀 생각하지 않습니다. –