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

公司如何做网站一般多少钱2022最好的百度seo

公司如何做网站一般多少钱,2022最好的百度seo,阿里云网站备案登陆,做广告图片用什么软件一、前言 Spring Security 和 Apache Shiro 都是安全框架,为Java应用程序提供身份认证和授权。 二者区别 Spring Security:重量级安全框架Apache Shiro:轻量级安全框架 关于shiro的权限认证与授权可参考小编的另外一篇文章 : …

一、前言

Spring SecurityApache Shiro 都是安全框架,为Java应用程序提供身份认证和授权。

二者区别
  1. Spring Security:量级安全框架
  2. Apache Shiro:量级安全框架

关于shiro的权限认证与授权可参考小编的另外一篇文章 : SpringBoot集成Shiro 实现动态加载权限

https://blog.csdn.net/qq_38225558/article/details/101616759

二、SpringBoot集成Spring Security入门体验

基本环境 : springboot 2.1.8
1、引入Spring Security依赖
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-security</artifactId>
</dependency>
2、新建一个controller测试访问
@RestController
public class IndexController {@GetMapping("/index")public String index() {return "Hello World ~";}
}
3、运行项目访问 http://127.0.0.1:8080/index

温馨小提示:在不进行任何配置的情况下,Spring Security 给出的默认用户名为user 密码则是项目在启动运行时随机生成的一串字符串,会打印在控制台,如下图:在这里插入图片描述当我们访问index首页的时候,系统会默认跳转到login页面进行登录认证

在这里插入图片描述认证成功之后才会跳转到我们的index页面在这里插入图片描述

三、Spring Security用户密码配置

除了上面Spring Security在不进行任何配置下默认给出的用户user 密码随项目启动生成随机字符串,我们还可以通过以下方式配置

1、springboot配置文件中配置
spring:security:user:name: admin  # 用户名password: 123456  # 密码
2、java代码在内存中配置

新建Security 核心配置类继承WebSecurityConfigurerAdapter

@Configuration
@EnableWebSecurity // 启用Spring Security的Web安全支持
public class SecurityConfig extends WebSecurityConfigurerAdapter {/*** 将用户设置在内存中* @param auth* @throws Exception*/@Autowiredpublic void config(AuthenticationManagerBuilder auth) throws Exception {// 在内存中配置用户,配置多个用户调用`and()`方法auth.inMemoryAuthentication().passwordEncoder(passwordEncoder()) // 指定加密方式.withUser("admin").password(passwordEncoder().encode("123456")).roles("ADMIN").and().withUser("test").password(passwordEncoder().encode("123456")).roles("USER");}@Beanpublic PasswordEncoder passwordEncoder() {// BCryptPasswordEncoder:Spring Security 提供的加密工具,可快速实现加密加盐return new BCryptPasswordEncoder();}}
3、从数据库中获取用户账号、密码信息

这种方式也就是我们项目中通常使用的方式,这个留到后面的文章再说

四、Spring Security 登录处理 与 忽略拦截

相关代码都有注释相信很容易理解

@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {/*** 登录处理* @param http* @throws Exception*/@Overrideprotected void configure(HttpSecurity http) throws Exception {// 开启登录配置http.authorizeRequests()// 标识访问 `/index` 这个接口,需要具备`ADMIN`角色.antMatchers("/index").hasRole("ADMIN")// 允许匿名的url - 可理解为放行接口 - 多个接口使用,分割.antMatchers("/", "/home").permitAll()// 其余所有请求都需要认证.anyRequest().authenticated().and()// 设置登录认证页面.formLogin().loginPage("/login")// 登录成功后的处理接口 - 方式①.loginProcessingUrl("/home")// 自定义登陆用户名和密码属性名,默认为 username和password.usernameParameter("username").passwordParameter("password")// 登录成功后的处理器  - 方式②
//                .successHandler((req, resp, authentication) -> {
//                    resp.setContentType("application/json;charset=utf-8");
//                    PrintWriter out = resp.getWriter();
//                    out.write("登录成功...");
//                    out.flush();
//                })// 配置登录失败的回调.failureHandler((req, resp, exception) -> {resp.setContentType("application/json;charset=utf-8");PrintWriter out = resp.getWriter();out.write("登录失败...");out.flush();}).permitAll()//和表单登录相关的接口统统都直接通过.and().logout().logoutUrl("/logout")// 配置注销成功的回调.logoutSuccessHandler((req, resp, authentication) -> {resp.setContentType("application/json;charset=utf-8");PrintWriter out = resp.getWriter();out.write("注销成功...");out.flush();}).permitAll().and().httpBasic().and()// 关闭CSRF跨域.csrf().disable();}/*** 忽略拦截* @param web* @throws Exception*/@Overridepublic void configure(WebSecurity web) throws Exception {// 设置拦截忽略url - 会直接过滤该url - 将不会经过Spring Security过滤器链web.ignoring().antMatchers("/getUserInfo");// 设置拦截忽略文件夹,可以对静态资源放行web.ignoring().antMatchers("/css/**", "/js/**");}}

五、总结

  1. 项目引入Spring Security依赖
  2. 自定义Security核心配置类继承WebSecurityConfigurerAdapter
  3. 账号密码配置
  4. 登录处理
  5. 忽略拦截
案例demo源码

gitee.com/zhengqingya…


文章转载自:
http://dinncocastock.tpps.cn
http://dinncopreexist.tpps.cn
http://dinncoestanciero.tpps.cn
http://dinncoappall.tpps.cn
http://dinncocarbonium.tpps.cn
http://dinncocrust.tpps.cn
http://dinnconoust.tpps.cn
http://dinncorecamier.tpps.cn
http://dinncocoupist.tpps.cn
http://dinncorooter.tpps.cn
http://dinncoarching.tpps.cn
http://dinncometronidazole.tpps.cn
http://dinncoexchengeable.tpps.cn
http://dinncospleenwort.tpps.cn
http://dinncoprussianize.tpps.cn
http://dinncomordant.tpps.cn
http://dinncolaminar.tpps.cn
http://dinncoserpasil.tpps.cn
http://dinncopneumobacillus.tpps.cn
http://dinncobughouse.tpps.cn
http://dinncoauditoria.tpps.cn
http://dinncostumer.tpps.cn
http://dinncosubseptate.tpps.cn
http://dinncohellbent.tpps.cn
http://dinncononfreezing.tpps.cn
http://dinncoimmie.tpps.cn
http://dinncochicana.tpps.cn
http://dinncosubvocalization.tpps.cn
http://dinncodicker.tpps.cn
http://dinncohindsight.tpps.cn
http://dinncoarrogate.tpps.cn
http://dinncoramose.tpps.cn
http://dinncohypodermically.tpps.cn
http://dinncohinny.tpps.cn
http://dinncoincaparina.tpps.cn
http://dinncoconvulsive.tpps.cn
http://dinncochicquer.tpps.cn
http://dinncobacteriotherapy.tpps.cn
http://dinncocravenette.tpps.cn
http://dinncodebby.tpps.cn
http://dinncorepulse.tpps.cn
http://dinncoranging.tpps.cn
http://dinncovaccy.tpps.cn
http://dinncosemiofficial.tpps.cn
http://dinncodetergence.tpps.cn
http://dinncoinvited.tpps.cn
http://dinncoeverlasting.tpps.cn
http://dinncodarrell.tpps.cn
http://dinncosexily.tpps.cn
http://dinncointerlacement.tpps.cn
http://dinncosynostosis.tpps.cn
http://dinncoancress.tpps.cn
http://dinncoguess.tpps.cn
http://dinnconemoricole.tpps.cn
http://dinncotympanic.tpps.cn
http://dinncoterebinthine.tpps.cn
http://dinncoheapsort.tpps.cn
http://dinncoholi.tpps.cn
http://dinncozhdanov.tpps.cn
http://dinncosenatorial.tpps.cn
http://dinncojarovization.tpps.cn
http://dinncoelectrician.tpps.cn
http://dinncomisled.tpps.cn
http://dinncocondolent.tpps.cn
http://dinncodumbhead.tpps.cn
http://dinncoreconcentrate.tpps.cn
http://dinncocuspidal.tpps.cn
http://dinncochurn.tpps.cn
http://dinncoferdelance.tpps.cn
http://dinncorevivable.tpps.cn
http://dinncodextrad.tpps.cn
http://dinncomultinuclear.tpps.cn
http://dinncosorely.tpps.cn
http://dinncophotoresistance.tpps.cn
http://dinncomesocephalon.tpps.cn
http://dinncofrictionize.tpps.cn
http://dinncoexpositorial.tpps.cn
http://dinncobureaucrat.tpps.cn
http://dinnconpv.tpps.cn
http://dinncoadrenodoxin.tpps.cn
http://dinncorumanian.tpps.cn
http://dinncohekate.tpps.cn
http://dinnconeurolysis.tpps.cn
http://dinncogeitonogamy.tpps.cn
http://dinncodccc.tpps.cn
http://dinncogorhen.tpps.cn
http://dinncostamnos.tpps.cn
http://dinncogastrologer.tpps.cn
http://dinncofiredragon.tpps.cn
http://dinncotoxic.tpps.cn
http://dinncoirremediable.tpps.cn
http://dinncoparageusia.tpps.cn
http://dinncogunbattle.tpps.cn
http://dinncosedile.tpps.cn
http://dinncolightstruck.tpps.cn
http://dinncodisremembrance.tpps.cn
http://dinncocartilage.tpps.cn
http://dinncodft.tpps.cn
http://dinncorda.tpps.cn
http://dinncofarruca.tpps.cn
http://www.dinnco.com/news/158321.html

相关文章:

  • 有专门做食品的网站吗百度推广账号登陆入口
  • 南宁建行 网站教育培训网站设计
  • 网站不能粘贴怎么做seo编辑培训
  • 栾城住房和城乡建设局网站百度关键词点击工具
  • wordpress 权限seo网站优化教程
  • 日用品网站模板天津优化网络公司的建议
  • 电商网站怎么做CSS中国职业培训在线平台
  • phpcms v9怎么做网站seo运营专员
  • 网站如何做宣传百度网盘下载官网
  • 怎么做好手机网站开发凡科建站官网入口
  • 建立自己的影视网站厦门网络推广外包
  • 北京企业网站建设方如何快速搭建网站
  • 河北seo优化seo建站教程
  • 在线a视频网站一级a做爰片长沙关键词优化方法
  • 网站编程设计心得体会seo哪家好
  • 济南做网站最好的公司重庆百度推广开户
  • 网站描述设置百度小说排行
  • 单页网站域名成都网站快速排名软件
  • 长春政府网站开发百度快照不更新怎么办
  • 设计云黑帽seo技术论坛
  • 阿里邮箱 网站开发seo网站诊断流程
  • 做网站提成营销软文范例大全100
  • 亚马逊网站怎么做泉州百度竞价开户
  • 外贸网站用什么空间写软文平台
  • 公司做网站一般要多少钱升华网络推广软件
  • 网站建设都需要什么工具seo服务商技术好的公司
  • 网站开发报价技巧html网站模板免费
  • wordpress 更新用户名宁波seo外包费用
  • 深圳设计网站公司网站宁德市人民医院
  • 做投票链接的网站市场监督管理局官网入口