SpringBoot整合SpringSecurity - Go语言中文社区

SpringBoot整合SpringSecurity


先说下项目结构

https://img-blog.csdnimg.cn/20181229105258777

https://img-blog.csdnimg.cn/20181229105258824

https://img-blog.csdnimg.cn/20181229105258876


解决thymeleaf报错问题

pom文件中加

https://img-blog.csdnimg.cn/20181229105258924

正文


1 引入SpringSecurity

https://img-blog.csdnimg.cn/20181229105258972

​​

2 编写配置类

官网描述

自己写的


3 控制请求访问权限

https://img-blog.csdnimg.cn/2018122910525918

​​启动运行

https://img-blog.csdnimg.cn/2018122910525975

​​

主页可以访问,子页面都无法访问


开启自动配置的登陆功能

https://img-blog.csdnimg.cn/20181229105259141

当请求到权限不足的页面的时候,会跳转到登陆页面

https://img-blog.csdnimg.cn/20181229105259181

​ps:如果登陆错误 重定向到 /login?error表示登陆失败


设置认证规则

https://img-blog.csdnimg.cn/20181229105259225

整个配置文件

https://img-blog.csdnimg.cn/20181229105259303

https://img-blog.csdnimg.cn/20181229105259366

​​

https://img-blog.csdnimg.cn/20181229105259407

发现可以访问了


完成注册功能

https://img-blog.csdnimg.cn/20181229105259503

为了方便修改一下

https://img-blog.csdnimg.cn/20181229105259558

https://img-blog.csdnimg.cn/20181229105259617

​​

https://img-blog.csdnimg.cn/20181229105259658

https://img-blog.csdnimg.cn/20181229105259700

输入账号密码

https://img-blog.csdnimg.cn/20181229105259747

​​点击按钮注销即可


定义注销规则

https://img-blog.csdnimg.cn/20181229105259787

​​


开启记住我功能

https://img-blog.csdnimg.cn/20181229105259829

https://img-blog.csdnimg.cn/20181229105259868

当勾住后,把浏览器关了点开还是有的。


定制自己的登陆页面

https://img-blog.csdnimg.cn/20181229105259919

https://img-blog.csdnimg.cn/20181229105259960

配置即可

 

版权声明:本文来源CSDN,感谢博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/u014131617/article/details/85335646
站方申明:本站部分内容来自社区用户分享,若涉及侵权,请联系站方删除。
  • 发表于 2020-03-08 14:18:30
  • 阅读 ( 1272 )
  • 分类:

0 条评论

请先 登录 后评论

官方社群

GO教程

猜你喜欢