Spring Security-在sessionManagement中的expiredUrl上显示HTML页面 [英] Spring Security - display HTML page on expiredUrl in sessionManagement

查看:107
本文介绍了Spring Security-在sessionManagement中的expiredUrl上显示HTML页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的java spring安全性中配置 expiredUrl(")功能.
我想在并发会话过期时显示HTML页面
我尝试了以下方式:-

I want to configure expiredUrl(" ") feature in my java spring security.
I want to display HTML page when my concurrent session get expired
I tried in following way:-

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页面

My context path set as localhost:8080/context_path but
I am not getting how to display session_expired.html page on expiredUrl call
I am using angularJs on Js side
Please help me to display Html page on expiredUrl call

AND

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

If I tried with the help of Js then my code is:-

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

here when session get expired it will goes on link localhost:8080/context_path/session_expired#/landing...
but I want to go on link
localhost:8080/context_path/#/session_expired

OR

我想在 expiredUrl
上显示直接HTML页面所以请指导我该怎么做.

I want to display direct HTML page on expiredUrl
so please guide me how to do this.

推荐答案

此配置对我有用:

 @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");
    }

这篇关于Spring Security-在sessionManagement中的expiredUrl上显示HTML页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆