当前位置: 首页 > 知识库问答 >
问题:

Spring security logout-仅在登录用户触发注销时添加消息

徐俊楚
2023-03-14
@RequestMapping(value ="/logout", method = RequestMethod.GET)
    public ModelAndView logout(HttpServletRequest request, HttpServletResponse response) {
            ModelAndView model = new ModelAndView();
       //some code here to distingish
            model.addObject("msg", "You are succesfully logged out!");
            model.setViewName("login");
        return model;
    }
<http auto-config="true" create-session="ifRequired" use-expressions="true">        
<intercept-url pattern="/logout" access="IS_AUTHENTICATED_REMEMBERED"/>
    <form-login 
        login-page="/login" 
        default-target-url="/home" 
        authentication-failure-url="/login?error" 
        username-parameter="username"
        password-parameter="password" />
    <logout logout-success-url="/logout" invalidate-session="true" delete-cookies="JSESSIONID"/>
    <!-- enable csrf protection -->
    <csrf/>
</http>

<authentication-manager>
    <authentication-provider>
        <user-service>
            <user name="mkyong" password="123456" authorities="ROLE_USER" />
        </user-service>
    </authentication-provider>
</authentication-manager>

共有1个答案

寇景明
2023-03-14
<intercept-url pattern="/logout" access="IS_AUTHENTICATED_REMEMBERED"/>
protected void configure(HttpSecurity http) throws Exception {
    http
        .authorizeRequests()
            .antMatchers("/logout").authenticated()
            ...
}
 类似资料:
  • 用户登录 在用户登录App账号时调用以下登录方法,从而保证用户是以登录身份进行咨询,是区分会话的用户的唯一标识; 游客咨询不需要调用小能login方法,小能会自动生成一个游客身份标识,在客服端游客身份的用户名显示为:“游客+4位数字”。 App完全退出(被杀掉进程), 再次进入时, 在SDK初始化之后, 如果App本身账号是登录用户, 需要重新调用小能SDK登陆接口,同步用户身份【大多是针对App

  • 登录与注销 用户登录 在App登录的地方,调用小能的login方法,目的是传递账号信息,为客服端显示用户信息。在App被杀死之后,sdk会保持用户的登录状态,不需要再次调用登录的方法。 uid作为用户的唯一标识需要保证唯一性,username可根据需要传入手机号、昵称等信息 /** * @param uid 必填,登录用户的id, 只能输入数字、英文字母和"@._—"四种字符,长度小于等于60位

  • Firebase存储电子邮件和密码。 我需要在注册中添加用户名。 我还需要使用用户名/密码而不是电子邮件/密码对(登录)用户进行身份验证。 注册应包含用户名、电子邮件和密码。。。 而登录时应使用用户名和密码。 注册Activity.java } 后勤活动。Java语言

  • 问题内容: 我们正在使用Spring 3开发RESTful Web服务,我们需要具有登录和注销功能,例如和。会话应存储在上下文中,直到会话超时或注销以允许使用其他Web服务。没有会话信息的任何访问Web服务的请求都应被拒绝。寻找这种情况的最新解决方案。 我实际上是在复活这里Spring Security 3以编程方式登录的问题,仍然无法正确回答。请同时在web.xml中指定所需的更改。 问题答案:

  • 我正在尝试清除会话,并在会话超时时将用户注销,并重定向到登录页面。登录页是帐户控制器中的登录方法返回的部分视图。当会话超时时,登录视图会在当前页面中呈现用户在会话超时之前所在的页面以及URL。 Web.config

  • 嗨,我想让我的用户通过URL登录,这是由Spring Security的。URL将包含用户名和密码。我尝试通过controller向customAuthenticationManager发送用户名和密码,然后签入CustomAuthentication Provider并返回UsernamePasswordAuthenticationToken。当我检查isauthenticated标志时,它显示