2017-03-20 5 views
0

일부 구성이 누락되었다고 확신합니다.Identity Server를 사용하여 20 분 동안 세션 시간 초과 쿠키 인증을 사용하는 하이브리드 흐름

아래와 같이 구성된 하이브리드 흐름에서 ASP.NET 코어 1.0 웹 사이트로 Identity Server 4을 사용하여 새 앱을 테스트하고 있습니다.

 app.UseCookieAuthentication(new CookieAuthenticationOptions 
     { 
      AuthenticationScheme = "Cookies" 
     }); 

     app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions 
     { 
      AuthenticationScheme = "oidc", 
      SignInScheme = "Cookies", 
      Authority = "https://account.testsite.com", 
      RequireHttpsMetadata = true, 
      ClientId = "superId", 
      ClientSecret = "supersecretclient", 

      ResponseType = "code id_token", 
      Scope = { "api1", "offline_access", "profile", "openid" }, 

      GetClaimsFromUserInfoEndpoint = true, 
      SaveTokens = true, 

      TokenValidationParameters = new TokenValidationParameters 
      { 
       NameClaimType = "name", 
       RoleClaimType = "role" 
      } 
     }); 

사용자는 웹 사이트에서의 활동과 관계없이 20 분이 지나면 로그 아웃됩니다. IdSrv4에 대한

클라이언트 설정은 다음과 같이이 :

Absolute refresh time: 2592000 Access token lifetime: 3600 Authorization code lifetime: 300 Identity token lifetime: 300 Sliding refresh token lifetime: 1296000

사용자 히트 페이지에서 새로 고침 경우

, 그는 즉시 그러나, 페이지가 실패 자동로드 기능을 가지고, 다시 자동으로 기록됩니다.

+0

이 원하는 무엇 당신이 기대하는 행동? –

+0

기본 쿠키 시간이 29 일이라고 가정 할 때 원하는 동작이 액세스 토큰 수명만큼 1 시간 이상으로 예상됩니다 ... –

+0

질문에 클라이언트 구성을 게시하고 액세스 토큰 수명 3600 초, 그래서 1 시간입니다. 둘째, OpenIdConnectOptions의 [UseTokenLifetime'] (https://github.com/aspnet/Security/blob/10ef26d63c98c3966e7315aee172a7c3fd992520/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs#L235) 속성을 다음과 같이 사용할 수 있습니다. 세션 쿠키의 수명을 토큰의 수명과 동기화하십시오. 그러나 액세스 토큰이 아닌 ** ID ** 토큰 수명을 사용한다는 점을 알아 두십시오. –

답변

0

공식 ASP Identity 기능을 시도하지는 않았지만 쿠키를 사용하여 제 3 자 로그온을 구현하고 있습니다.

쿠키 인증 방법에는 다양한 옵션이 있습니다. 내 예제는 현재 응용 프로그램에서 가져온 것입니다. 중요한 것들 SlidingExpiration

app.UseCookieAuthentication(new CookieAuthenticationOptions() { 
    CookieName = "Company.MyApp.Web." + env.EnvironmentName.ToLower(), 
    AuthenticationScheme = "MyAppCookieAuth", 
    LoginPath = new PathString("/Home/Login/"), 
    AccessDeniedPath = new PathString("/Home/AccessDenied/"), 
    AutomaticAuthenticate = true, 
    AutomaticChallenge = true, 
    ExpireTimeSpan = TimeSpan.FromHours(2), 
    SlidingExpiration = true 
}); 

쿠키 절반 만료 된 때, 다음 페이지 요청에이 새로 고쳐집니다 ExpireTimeSpan 있습니다. 이렇게하면 더 오랜 기간 동안 로그인을 유지하는 데 도움이 될 수 있습니다.

쿠키 인증에 더 많은 정보 :

쿠키 미들웨어를 사용하여 ASP.NET 코어 정체성없이 - https://docs.microsoft.com/en-us/aspnet/core/security/authentication/cookie

정체성에 대한 소개 (섹션 쿠키에 관한 포함)

- https://docs.microsoft.com/en-us/aspnet/core/security/authentication/identity