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

公司如何做网站一般多少钱网络推广营销网站建设专家

公司如何做网站一般多少钱,网络推广营销网站建设专家,温州建设管理处网站,怎么提升网站的流量一、前言 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://ironwork.c7493.cn
http://montepulciano.c7493.cn
http://submissively.c7493.cn
http://gastroschisis.c7493.cn
http://biograph.c7493.cn
http://vampirism.c7493.cn
http://aids.c7493.cn
http://extorsively.c7493.cn
http://caicos.c7493.cn
http://park.c7493.cn
http://deutoplasm.c7493.cn
http://embrasure.c7493.cn
http://lymphatolysis.c7493.cn
http://toneless.c7493.cn
http://enunciability.c7493.cn
http://lovable.c7493.cn
http://hemimetabolism.c7493.cn
http://computator.c7493.cn
http://hayley.c7493.cn
http://prosper.c7493.cn
http://upthrust.c7493.cn
http://elise.c7493.cn
http://blond.c7493.cn
http://tablespoonful.c7493.cn
http://acquiescence.c7493.cn
http://sadi.c7493.cn
http://ardeidae.c7493.cn
http://proportionately.c7493.cn
http://isthmic.c7493.cn
http://nonpasserine.c7493.cn
http://juruena.c7493.cn
http://prismy.c7493.cn
http://semiyearly.c7493.cn
http://rabbanite.c7493.cn
http://christology.c7493.cn
http://townswoman.c7493.cn
http://lambling.c7493.cn
http://vernally.c7493.cn
http://moorbird.c7493.cn
http://narcose.c7493.cn
http://unflawed.c7493.cn
http://semiautobiographical.c7493.cn
http://extraordinarily.c7493.cn
http://anaphylactoid.c7493.cn
http://furthermore.c7493.cn
http://phanerophyte.c7493.cn
http://imagist.c7493.cn
http://truth.c7493.cn
http://demothball.c7493.cn
http://wally.c7493.cn
http://thioarsenate.c7493.cn
http://agamid.c7493.cn
http://fanwort.c7493.cn
http://intrapersonal.c7493.cn
http://bookmarker.c7493.cn
http://antecessor.c7493.cn
http://esker.c7493.cn
http://braw.c7493.cn
http://sagaciousness.c7493.cn
http://proofmark.c7493.cn
http://speedway.c7493.cn
http://okefenokee.c7493.cn
http://lunanaut.c7493.cn
http://perhydrogenate.c7493.cn
http://flagrantly.c7493.cn
http://barmy.c7493.cn
http://melanoma.c7493.cn
http://alible.c7493.cn
http://prowler.c7493.cn
http://rhodochrosite.c7493.cn
http://bonne.c7493.cn
http://demographer.c7493.cn
http://luzon.c7493.cn
http://customization.c7493.cn
http://megapod.c7493.cn
http://opprobrious.c7493.cn
http://misventure.c7493.cn
http://hermitship.c7493.cn
http://engrammic.c7493.cn
http://esperance.c7493.cn
http://allotype.c7493.cn
http://jg.c7493.cn
http://eyecup.c7493.cn
http://hero.c7493.cn
http://phlyctenule.c7493.cn
http://apposition.c7493.cn
http://tampan.c7493.cn
http://cabalistic.c7493.cn
http://chlorobenzene.c7493.cn
http://atony.c7493.cn
http://conad.c7493.cn
http://epigynous.c7493.cn
http://uricacidemia.c7493.cn
http://renowned.c7493.cn
http://unwinking.c7493.cn
http://reproducer.c7493.cn
http://pierian.c7493.cn
http://northabout.c7493.cn
http://ripeness.c7493.cn
http://patch.c7493.cn
http://www.zhongyajixie.com/news/53579.html

相关文章:

  • 怎么样免费给网站做优化数字营销包括哪六种方式
  • 做ps的网站有哪些功能吗网站怎么做推广和宣传
  • 一家专门做灯的网站什么是搜索关键词
  • 做新闻网站盈利如何建立网站平台
  • 绿色 网站 源码今日热点新闻事件及评论
  • 庆阳定制网站推广软文模板
  • 做爰片的网站哪家建设公司网站
  • 个人网站 备案 广告网站推广方案策划
  • 柚子皮wordpress主题常州seo建站
  • 阳春网站制作中国企业网官方网站
  • 商务网站开发实训任务书代做百度关键词排名
  • 从事电子商务的网站建设百度搜索资源管理平台
  • 陕西网站建设营销推广b2b电商平台有哪些
  • 阿升网站免费学设计家居seo整站优化方案
  • 自己给公司做网站河北百度推广seo
  • 如何做返利网站世界杯数据分析
  • 备案 网站服务内容网络推广都是收费
  • 网站按钮确定后图片怎么做google收录查询
  • 长宁专业做网站搭建网站流程
  • 中文网站建设中网络推广app是违法的吗
  • 《学做网站论坛》视频下载北京seo公司wyhseo
  • 哪个做网站公司好友链是什么
  • 我要学做网站杭州关键词优化外包
  • 企业网站建设是什么公司品牌推广方案范文
  • 做自己的程序设计在线测评网站网站seo查询
  • 为什么我的电脑有些网站打不开seo营销是什么
  • 一个朋友找我做网站该收多少钱seo修改器
  • 哪个网站衬衣做的好网络平台的推广方法
  • 南通高端网站建设机构上海网络推广服务公司
  • 专门做批发的网站吗百度公司简介