2016-11-08 5 views
3

나는 identityserver에 의해 관리되는 권한을 가진 MVC 응용 프로그램을 가지고 있습니다. 처음 웹에 액세스하면 identityserver 로그 페이지로 리디렉션되며 웹에 다시 리디렉션됩니다.자동 로그인을 비활성화하는 방법 IdentityServer

내 문제는 아이디 서버를 로그 아웃하면 아이디 서버 권한으로 아이디 서버로 리디렉션됩니다.하지만 아이디 입력없이 사용자 웹에 액세스 할 수있게됩니다.

나는 쿠키가 클라이언트에서 여전히 살아 있기 때문에 (나는 내 ​​브라우저에서 수동으로 모든 쿠키를 삭제 한 다음 사용자/패스가 필요하다) 때문이다.

어떻게 자동 로그인을 비활성화 할 수 있습니까? (사용자/패스가 항상 필요합니다)?

내 시작 클라이언트 구성과 같은 것입니다 : 사전에

app.UseCookieAuthentication(new CookieAuthenticationOptions 
     { 
      LoginPath = new PathString("/Home/Logged/"), 
      AuthenticationType = "Cookies", 
      ExpireTimeSpan = TimeSpan.FromDays(2), 
      SlidingExpiration = true, 
      CookieName = ".AspNet.MyApp" 

     }); 


     app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions 
     { 
      ClientId = "MyApp", 
      Authority = IS_URL, 
      RedirectUri = localHostURL + "/Home/Logged/", 
      PostLogoutRedirectUri = localHostURL + "/Account/Login/", 
      ResponseType = "code id_token token", 
      Scope = "openid profile read write sampleApi", 
      SignInAsAuthenticationType = "Cookies", 

      UseTokenLifetime = true, 

      Notifications = new OpenIdConnectAuthenticationNotifications 
      { 
       SecurityTokenValidated = async n => 
       { 
        var nid = new ClaimsIdentity(
         n.AuthenticationTicket.Identity.AuthenticationType, 
         "given_name", 
         "role"); 

        // get userinfo data 
        var userInfoClient = new UserInfoClient(
         new System.Uri(n.Options.Authority + "/connect/userinfo"), 
         n.ProtocolMessage.AccessToken); 

        var userInfo = await userInfoClient.GetAsync(); 
        userInfo.Claims.ToList().ForEach(ui => nid.AddClaim(new Claim(ui.Item1, ui.Item2))); 

        //keep the id_token for logout 

        nid.AddClaim(new Claim("id_token", n.ProtocolMessage.IdToken)); 

        // add access token for sample API 
        nid.AddClaim(new Claim("access_token", n.ProtocolMessage.AccessToken)); 

        // keep track of access token expiration 
        nid.AddClaim(new Claim("expires_at", TimeSpan.FromDays(2).ToString())); 

        // add some other app specific claim 
        nid.AddClaim(new Claim("app_specific", "some data")); 

        n.AuthenticationTicket = new AuthenticationTicket(
         nid, 
         n.AuthenticationTicket.Properties); 
       }, 
       RedirectToIdentityProvider = n => 
       { 
        if (n.ProtocolMessage.RequestType == OpenIdConnectRequestType.LogoutRequest) 
        { 
         var idTokenHint = n.OwinContext.Authentication.User.FindFirst("id_token"); 

         if (idTokenHint != null) 
         { 
          n.ProtocolMessage.IdTokenHint = idTokenHint.Value; 
         } 
        } 

        return Task.FromResult(0); 
       } 
      } 
     }); 

감사합니다!

답변

0

idsrv 로의 로그인 요청/리디렉션의 경우 매개 변수를 login으로 설정하십시오.

OnRedirectToIdentityProvider = n => 
{ 

    if (n.ProtocolMessage.RequestType == OpenIdConnectRequestType.Authentication) 
    {  
     n.ProtocolMessage.Prompt = "login"; 
    } 

    return Task.FromResult(0); 
} 

IdSrv docs 사용자가 이미 로그인 유효한 세션을 가지고있다하더라도,

prompt (optional)

login 로그인 UI

가 표시됩니다 (프롬프트 참조). OpenId Connect spec around /authorize requests

prompt=login

권한 부여 서버가 재 인증을위한 최종 사용자 메시지를 표시해야한다

. 최종 사용자를 재 인증 할 수없는 경우 오류 (일반적으로 login_required)를 반환해야합니다.

0

:

은 사양을 참조하십시오. 가장 우아한 방법은 아니지만 쿠키 만료를 10 초로 줄이고 슬라이딩 제거 기능을 해제하여 해결했습니다. 신뢰 당사자가 10 초 이내에 다시 돌아 오면 로그인 프롬프트가 무시됩니다.