日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

springboot security 权限不足_springBoot整合springSecurity(零一)

發布時間:2023/12/10 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 springboot security 权限不足_springBoot整合springSecurity(零一) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

整體結構===》》》

1,springboot2.0整合springSecurity5.1.1

2,mysql--->>InnoDB

3,持久層我用的是用MybatiysPlus(這里就不寫關于這個的了,基本是查)

4,web服務不是jar服務

5,數據庫表=》賬戶表/角色表/權限表/賬戶角色關聯表/角色權限關聯表

6,需要說一下的是角色表,給框架返回的角色碼需要以ROLE_開頭,

例如;

實現功能:

spring boot整合security

1,基于內存賬戶登陸

2,自定義數據庫賬戶角色權限登陸

3,結合security推薦加密賬戶密碼

4,自定義捕獲無權限訪問異常信息

5,控制session會話并捕獲超時異常

二:===================================================

去年寫過關于這兩個框架的東西,但現在回頭看以前寫的純粹是廢紙一張,不知道有沒有誤人子弟;

========================pom.xml==========================

<

====================application.yml=========================

#action YAML配置式 logging:level:org.springframework: INFOcom.example: DEBUG #服務端口 server:port: 8080servlet:session:#spring boot升級后必須要加時間標識秒timeout:10s spring: datasource: url: jdbc:mysql://127.0.0.1:3306/databaseName?useUnicode=true&characterEncoding=UTF-8&useSSL=falseusername: rootpassword: 172575 driverClassName : com.mysql.jdbc.Driverthymeleaf:prefix : classpath:/templates/ #掃描文件路徑suffix : .html #文件格式cache : false #關閉緩存encoding: UTF-8 #編碼格式#content-type:text/html #加載網頁內容 mode: HTML5 mybatis:mapperlocations : classpath:mapper/*.xmltypealiasespackage : springSecurity.enity

===================Application.java==========================

package

===================SecurityConfig.java========================

package

========================SecurityService=====================

package

========================ExceptionSecurity.java=================

package

========================WebContorller.java===================

package springSecurity;import java.util.UUID; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import springSecurity.dto.SysRole; import springSecurity.dto.SysUser; import springSecurity.service.SysRoleService; import springSecurity.service.SysUseraccount;/*** @author Administrator zpy 20181110*/ @Controller public class WebContorller {private static Logger logger = LoggerFactory.getLogger(WebContorller.class);@AutowiredSysUseraccount sysUserService;@AutowiredSysRoleService sysRoleService;// 默認轉向登陸@RequestMapping("/")public String loading() {return "login";}// login action@RequestMapping(value = "/login")public String userLogin() {return "login";}// 進入主菜單@RequestMapping(value = "/index")public String index() {return "index";}//權限不足拒絕頁面@RequestMapping("/403")public String Noloading() {return "403";}//session超時去往超時頁面@RequestMapping("timeOut")public String timeOut() {return "timeOut";}}

HTML頁面不太會寫,可以自己寫幾個簡單的html對應contorller的跳轉地址就成;

結語:

那幾個不太重要的service就不寫了,基本就是根據賬號查賬戶表信息,然后根據賬戶表的編號查角色賬戶關聯表,得到角色信息,然后根據角色信息返回給扽路賬戶進行正常訪問請求;

啟動以后,直接訪問htp://127.0.0.1:8080即可

總結

以上是生活随笔為你收集整理的springboot security 权限不足_springBoot整合springSecurity(零一)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。