首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Spring安全性-在expiredUrl上以sessionManagement显示HTML页面

Spring安全性-在expiredUrl上以sessionManagement显示HTML页面
EN

Stack Overflow用户
提问于 2016-06-29 19:38:17
回答 1查看 1.3K关注 0票数 2

我想在我的java spring安全性中配置expiredUrl(" ")特性。

我想在并发会话过期时显示HTML页面

我试着用以下方法:-

JAVA

代码语言:javascript
复制
@Override
public void configure(HttpSecurity http) throws Exception {
    http
            .sessionManagement()
            .sessionFixation()
            .changeSessionId()
            .maximumSessions(1)
            .expiredUrl("/session_expired.html")
}

我的上下文路径设置为localhost:8080/context_path,但是

我不知道如何在session_expired.html调用中显示expiredUrl页面

我在Js这边使用angularJs

请帮助我在expiredUrl调用中显示Html页面

如果我在Js的帮助下尝试,那么我的代码是:-

JAVA

代码语言:javascript
复制
@Override
public void configure(HttpSecurity http) throws Exception {
    http
            .sessionManagement()
            .sessionFixation()
            .changeSessionId()
            .maximumSessions(1)
            .expiredUrl("/access/session_expired")
}

ANGULARJS

代码语言:javascript
复制
$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页面

所以请指导我如何做这件事。

EN

回答 1

Stack Overflow用户

发布于 2016-06-29 20:33:52

此配置适用于我:

代码语言:javascript
复制
 @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");
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38108663

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档