我想在我的java spring security中配置expiredUrl(" ")
功能
我希望在我的并发会话到期时显示HTML页面
我尝试了以下方式: -
JAVA
@Override
public void configure(HttpSecurity http) throws Exception {
http
.sessionManagement()
.sessionFixation()
.changeSessionId()
.maximumSessions(1)
.expiredUrl("/session_expired.html")
}
我的上下文路径设置为localhost:8080/context_path
但
我没有得到如何在expiredUrl调用上显示session_expired.html
页面
我在Js一侧使用angularJs
请帮我在expiredUrl调用上显示Html页面
AND
如果我在Js的帮助下尝试过,那么我的代码是: -
JAVA
@Override
public void configure(HttpSecurity http) throws Exception {
http
.sessionManagement()
.sessionFixation()
.changeSessionId()
.maximumSessions(1)
.expiredUrl("/access/session_expired")
}
ANGULARJS
$stateProvider.state('session_expired', {
'url': '/session_expired',
'templateUrl': '/session_expired.html',
'controller': 'SessionExpiredController'
})
.factory('SessionService', function ($resource, restRoot, contextPath) {
return $resource({
'session_expired': {
'url': contextPath + '/access/session_expired'
},
})
.controller('SessionExpiredController', function (SessionService, $state) {
SessionService.session_expired(function () {
$state.go("session_expired");
});
});
当会话过期时,它将在链接localhost:8080/context_path/session_expired#/landing...
上发送
但我想继续链接
localhost:8080/context_path/#/session_expired
或
我想在expiredUrl
上显示直接HTML页面
所以请指导我如何做到这一点。
答案 0 :(得分:0)
此配置对我有用:
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/", "/list")
.access("hasRole('USER') or hasRole('ADMIN') or hasRole('DBA')")
.antMatchers("/newuser/**", "/delete-user-*").access("hasRole('ADMIN')").antMatchers("/edit-user-*")
.access("hasRole('ADMIN') or hasRole('DBA')").and().formLogin().loginPage("/login")
.loginProcessingUrl("/login").usernameParameter("ssoId").passwordParameter("password").and()
.rememberMe().rememberMeParameter("remember-me").tokenRepository(tokenRepository)
.tokenValiditySeconds(86400).and().csrf().and().exceptionHandling().accessDeniedPage("/Access_Denied");
}