我使用 jhipster 生成了一个应用程序并执行了 lib com.microsoft.azure 的所有设置。
登录工作正常,我的问题是当azure AD令牌过期(设置为1小时后过期)时我该如何处理。
我可以使用 SecurityConfiguration 中的过滤器来做到这一点吗?
@Override
public void configure(HttpSecurity http) throws Exception {
// @formatter:off
http
.csrf()
.csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse())
.and()
.addFilterBefore(corsFilter, CsrfFilter.class)
.exceptionHandling()
.accessDeniedHandler(problemSupport)
.and()
.headers()
.contentSecurityPolicy("default-src 'self'; frame-src 'self' data:; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://storage.googleapis.com; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:")
.and()
.referrerPolicy(ReferrerPolicyHeaderWriter.ReferrerPolicy.STRICT_ORIGIN_WHEN_CROSS_ORIGIN)
.and()
.featurePolicy("geolocation 'none'; midi 'none'; sync-xhr 'none'; microphone 'none'; camera 'none'; magnetometer 'none'; gyroscope 'none'; speaker 'none'; fullscreen 'self'; payment 'none'")
.and()
.frameOptions()
.deny()
.and()
.authorizeRequests()
.antMatchers("/api/users/**").hasRole("ADMIN")
.and()
.oauth2Login()
.userInfoEndpoint()
.oidcUserService(this.oidcUserService());
// @formatter:on
}
答案 0 :(得分:0)
令牌过期时有两种选择:一种是使用 refresh token 更新令牌,另一种是再次请求 ----------------------------------------
System information
----------------------------------------
Platform: Windows-10-10.0.16299-SP0
Python: 3.8.5
OpenCV: 4.5.1
----------------------------------------
端点以获取新令牌。
如果访问令牌过期,它将调用 /token
函数。还有一个类似的问题,请参阅 here。