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

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

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

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

整體結(jié)構(gòu)===》》》

1,springboot2.0整合springSecurity5.1.1

2,mysql--->>InnoDB

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

4,web服務(wù)不是jar服務(wù)

5,數(shù)據(jù)庫表=》賬戶表/角色表/權(quán)限表/賬戶角色關(guān)聯(lián)表/角色權(quán)限關(guān)聯(lián)表

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

例如;

實(shí)現(xiàn)功能:

spring boot整合security

1,基于內(nèi)存賬戶登陸

2,自定義數(shù)據(jù)庫賬戶角色權(quán)限登陸

3,結(jié)合security推薦加密賬戶密碼

4,自定義捕獲無權(quán)限訪問異常信息

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

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

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

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

<

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

#action YAML配置式 logging:level:org.springframework: INFOcom.example: DEBUG #服務(wù)端口 server:port: 8080servlet:session:#spring boot升級后必須要加時間標(biāo)識秒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 #關(guān)閉緩存encoding: UTF-8 #編碼格式#content-type:text/html #加載網(wǎng)頁內(nèi)容 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;// 默認(rèn)轉(zhuǎn)向登陸@RequestMapping("/")public String loading() {return "login";}// login action@RequestMapping(value = "/login")public String userLogin() {return "login";}// 進(jìn)入主菜單@RequestMapping(value = "/index")public String index() {return "index";}//權(quán)限不足拒絕頁面@RequestMapping("/403")public String Noloading() {return "403";}//session超時去往超時頁面@RequestMapping("timeOut")public String timeOut() {return "timeOut";}}

HTML頁面不太會寫,可以自己寫幾個簡單的html對應(yīng)contorller的跳轉(zhuǎn)地址就成;

結(jié)語:

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

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

總結(jié)

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

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。