当前位置: 首页 > news >正文

jsp书城网站开发宁波seo外包快速推广

jsp书城网站开发,宁波seo外包快速推广,wordpress 文章加评论,封面型网站首页怎么做我们初步引入了Spring Security#xff0c;并使用其默认生效的HTTP基本认证来保护URL资源#xff0c;本章我们使用表单认证来保护URL资源。 前后端分离模式 表单登录配置模块提供了successHandler#xff08;#xff09;和failureHandler#xff08;#xff09;两个方法…我们初步引入了Spring Security并使用其默认生效的HTTP基本认证来保护URL资源本章我们使用表单认证来保护URL资源。 前后端分离模式 表单登录配置模块提供了successHandler和failureHandler两个方法分别处理登录成功和登录失败的逻辑。其中successHandler()方法带有一个Authentication参数携带当前登录用户名及其角色等信息而failureHandler()方法携带一个AuthenticationException异常参数。具体处理方式需按照系统的情况自定义。 Content-Type: application/x-www-form-urlencoded;charsetUTF-8 package com.boot.config;import com.boot.security.LoginFailureHandler; import com.boot.security.LoginSuccessHandler; import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.Customizer; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.core.Authentication; import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.authentication.AuthenticationFailureHandler; import org.springframework.security.web.authentication.AuthenticationSuccessHandler;import java.io.IOException;import static org.springframework.security.config.Customizer.withDefaults;//EnableWebSecurity:开启SpringSecurity 之后会默认注册大量的过滤器servlet filter //过滤器链【责任链模式】SecurityFilterChain Configuration EnableWebSecurity public class SecurityConfig {Beanpublic SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {//authorizeHttpRequests:针对http请求进行授权配置//login登录接口需要匿名访问//permitAll:具有所有权限 也就可以匿名可以访问//anyRequest:任何请求 所有请求//authenticated:认证【登录】http.authorizeHttpRequests(authorizeHttpRequests-authorizeHttpRequests.requestMatchers(/login).permitAll().anyRequest().authenticated());//http:后面可以一直点 但是太多内容之后不美观//loginProcessingUrl:指定登录接口//successHandler:登录成功处理器//failureHandler:登录失败处理器//自定义登录接口http.formLogin(formLogin-formLogin.loginProcessingUrl(/login).permitAll().successHandler(new LoginSuccessHandler()).failureHandler(new LoginFailureHandler()));//Customizer.withDefaults():关闭//http.csrf(Customizer.withDefaults());//跨域漏洞防御:关闭//http.csrf(e-e.disable());//http.csrf(crsf-crsf.disable());//相当于 http.csrf(Customizer.withDefaults());http.csrf(e-e.disable());//封装的太过于抽象比较难以阅读代码【装X】http.cors(e-e.disable());//跨域拦截关闭return http.build();}}在形式上我们确实使用了SpringSecurity的表单认证功能并且自定义了表单登录页。但实际上这还远远不够。例如在实际系统中我们正常登录时使用的用户名和密码都来自数据库这里却都写在配置上。更进一步我们可以对每个登录用户都设定详细的权限而并非一个通用角色。这些内容将在后面章节讲解。
http://www.pierceye.com/news/835718/

相关文章:

  • 做一网站APP多少钱网站做照片
  • 会同县做网站设计网站的结构时
  • 行业门户网站制作百度权重是怎么来的
  • 巅云建站as.net 网站开发视频教程
  • 网站开发定制合同在哪个网站可以学做衣服
  • 关键词排行优化网站搜索引擎营销的主要方式有
  • 免费网站建设免费咨询wordpress安装环境搭建
  • 网站怎样和首页做链接地址广厦建设集团官方网站
  • 遂平县网站建设网站建站的类型
  • wordpress多用途主题排行建网站做优化
  • 那里可以做旅游网站的吗手机系统
  • 牙科医院网站源码开封建网站
  • 网站的内容做网站后端的全部步骤
  • 可以做软件的网站有哪些功能wordpress建站事例
  • 静态网站生成刚刚发生在昆明的大事
  • 牡丹江0453免费信息网站学生保险网站
  • 接网站开发项目万网网站后台登陆
  • 江苏网站建站系统平台生存曲线哪个网站可以做
  • 国内产品网站w源码1688index网站制作
  • 韩国网站域名网站推广是干嘛的
  • 怎样查询江西省城乡建设厅网站互联网行业简介
  • 芜湖网站建设推广网站开发者 地图
  • 保养车哪个网站做的好电商网站建设目的及网站的优势
  • 文化馆建设网站上海建设银行官网网站
  • 微信分销网站建设垂直网站建设步骤
  • 网站建设招聘简介应届生求职网站官网
  • 驾校网站建设中国建设银行信用卡中心网站
  • 网站开发中的文档代理网络是什么意思
  • 如何不让百度收录网站网页设计教程文字和图片
  • 深圳网站建设公司哪家最好WordPress文章查询插件