shishanglian

导航

Spring Security

... ...

 

https://www.bilibili.com/video/BV15a411A7kP?p=11&vd_source=f0af7e8672950f05b84e56e88f09f32c

 

 

方案一
httpSecurity.cors().and() // 开启跨域
.csrf().disable() // csrf禁用,因为不使用session
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS) // STATELESS(无状态): 表示应用程序是无状态的,不会创建会话。这意味着每个请求都是独立的,不依赖于之前的请求。适用于 RESTful 风格的应用。
.and().headers().frameOptions().disable()
.and().exceptionHandling().authenticationEntryPoint(authenticationEntryPoint) // 身份未认证时响应
.accessDeniedHandler(accessDeniedHandler); // 身份已经认证(登录),但是没有权限的情况的响应

————————————————

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

原文链接:https://blog.csdn.net/cominglately/article/details/135111250


方案二

protected void configure(HttpSecurity http) throws Exception {
http.formLogin()
.loginPage("/login/page")
.loginProcessingUrl("/login")
.successHandler(customAuthenticationSuccessHandler)
.failureHandler(customAuthenticationFailureHandler) // 认证失败处理器
.and()
.authorizeRequests()
.antMatchers("/login/page").permitAll()
.anyRequest().authenticated();
http.csrf().disable();
}
————————————————

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

原文链接:https://blog.csdn.net/tb9125256/article/details/124222346


方案三

 

 

posted on 2022-11-27 22:08  嘉合  阅读(23)  评论(0)    收藏  举报