亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Spring Boot WebSecurityConfig LogoutSuccessURL

Spring Boot WebSecurityConfig LogoutSuccessURL

蝴蝶不菲 2023-09-20 15:20:43
我正在開發一個 Spring Boot 項目和用于會話控制的 WebSecurityConfig。問題是,當會話過期時,我被重定向到/?sessionexpired我期望它應該重定向 o 的時候/?expiredsession。此外,當用戶注銷時,頁面會重定向到/?sessionexpired而不是/?logout.我的配置如下    @Override    protected void configure(HttpSecurity http) throws Exception {        http            .authorizeRequests()                .antMatchers("/thirdparty/**", "/webjars/**", "/sessionerror").permitAll()                .anyRequest().authenticated()                .and()            .formLogin()                .loginPage("/")                .failureUrl("/?error")                .defaultSuccessUrl("/dashboard")                .permitAll()                .and()            .logout()                .logoutUrl("/logout")                .logoutSuccessUrl("/?logout")                .logoutRequestMatcher(new AntPathRequestMatcher("/logout")) // override default of only allowing POST for logout so we can use a GET                .deleteCookies("remove")                .invalidateHttpSession(true)                .permitAll()                .and()            .sessionManagement()                .maximumSessions(1)                .expiredUrl("/?expiredsession")                .maxSessionsPreventsLogin(false)                .and()            .invalidSessionUrl("/?sessionexpired");    }有人可以幫我解決這個問題嗎?
查看完整描述

1 回答

?
白衣非少年

TA貢獻1155條經驗 獲得超0個贊

所以我最終想通了。它正在重定向,/?sessionexpired因為在注銷時我通過將其設置為 true 來使Session失效。我應該將其設置為 false,然后用于.deleteCookies("JSESSIONID")使會話無效。這樣它就會正確重定向。



查看完整回答
反對 回復 2023-09-20
  • 1 回答
  • 0 關注
  • 99 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號