SpringBoot后台管理系统框架
SpringBoot后台管理系统框架
SpringBoot后台管理系统功能介绍
登录 注册 用户列表和添加功能
只是个框架 实现了shiro权限控制, 详细的shiro使用
一个模板项目系统 只有少量功能
使用技术
SpringBoot框架
Mysql数据库
redis
shiro权限
thymeleaf(前端)
功能展示
shiro权限
package com.game.app.shiro;import com.game.app.model.system.Permission;
import com.game.app.model.system.Role;
import com.game.app.model.system.User;
import com.game.app.service.system.AuthService;
import com.game.app.service.system.UserService;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.*;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.authz.SimpleAuthorizationInfo;
import org.apache.shiro.realm.AuthorizingRealm;
import org.apache.shiro.subject.PrincipalCollection;
import org.apache.shiro.subject.Subject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;import java.util.List;/*** 自定义权限匹配和账号密码匹配*/
@Service
public class MyShiroRealm extends AuthorizingRealm {private static final Logger logger = LoggerFactory.getLogger(MyShiroRealm.class);@Autowiredprivate AuthService authService;@Autowiredprivate UserService userService;/*** 此方法调用 hasRole,hasPermission的时候才会进行回调.* 权限信息.(授权):* 1、如果用户正常退出,缓存自动清空;* 2、如果用户非正常退出,缓存自动清空;* 3、如果我们修改了用户的权限,而用户不退出系统,修改的权限无法立即生效。* (需要手动编程进行实现;放在service进行调用)* 在权限修改后调用realm中的方法,realm已经由spring管理,所以从spring中获取realm实例,* 调用clearCached方法;* :Authorization 是授权访问控制,用于对用户进行的操作授权,证明该用户是否允许进行当前操作,如访问某个链接,某个资源文件等。*/@Overrideprotected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) {/** 当没有使用缓存的时候,不断刷新页面的话,这个代码会不断执行,* 当其实没有必要每次都重新设置权限信息,所以我们需要放到缓存中进行管理;* 当放到缓存中时,这样的话,doGetAuthorizationInfo就只会执行一次了,* 缓存过期之后会再次执行。*/logger.debug("权限配置-->MyShiroRealm.doGetAuthorizationInfo()");// 获取当前登陆用户Subject subject = SecurityUtils.getSubject();User user = (User) subject.getPrincipal();// 添加权限 和 角色信息SimpleAuthorizationInfo authorizationInfo = new SimpleAuthorizationInfo();// 根据用户id查询用户的角色List<Role> roles = authService.selectRoleByUserId(user.getId());if (null != roles && roles.size() > 0) {for (Role role : roles) {//添加角色authorizationInfo.addRole(role.getRoleName());//根据角色查询对应权限数据List<Permission> permissions = authService.selectPermissionByRoleId(role.getId());if (null != permissions && permissions.size() > 0) {// 授权角色下所有权限for (Permission permission : permissions) {authorizationInfo.addStringPermission(permission.getName());}}}}return authorizationInfo;}/*** 认证信息.(身份验证)* Authentication 是用来验证用户身份* 主要是用来进行身份认证的,也就是说验证用户输入的账号和密码是否正确*/@Overrideprotected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken)throws AuthenticationException {logger.debug("用户登录身份认证-->MyShiroRealm.doGetAuthenticationInfo()");//UsernamePasswordToken用于存放提交的登录信息UsernamePasswordToken token = (UsernamePasswordToken)authenticationToken;logger.info("用户登录认证:验证当前Subject时获取到token为:" +ReflectionToStringBuilder.toString(token, ToStringStyle.MULTI_LINE_STYLE));String username = token.getUsername();// 调用数据层 查询用户User user = userService.selectByUsername(username);logger.debug("用户登录认证!用户信息user:" + user);if (user == null) {// 用户不存在return null;} else {// 密码存在//盐值加密: 交给AuthenticatingRealm使用CredentialsMatcher进行密码匹配,如果觉得人家的不好可以自定义实现
// SimpleAuthenticationInfo authenticationInfo = new SimpleAuthenticationInfo(
// user, //用户名
// user.getPassword(), //密码
// ByteSource.Util.bytes(user.getCredentialsSalt()),//salt=username+salt
// getName() //realm name
// );//明文: 若存在,将此用户存放到登录认证info中,无需自己做密码对比,Shiro会为我们进行密码对比校验
// SimpleAuthenticationInfo authenticationInfo = new SimpleAuthenticationInfo(
// user, //用户名
// user.getPassword(), //密码
// getName() //realm name
// );//普通md5: Shiro会为我们进行密码对比校验// 第一个参数 ,登陆后,需要在session保存数据// 第二个参数,查询到密码(加密规则要和自定义的HashedCredentialsMatcher中的HashAlgorithmName散列算法一致)// 第三个参数 ,realm名字SimpleAuthenticationInfo authenticationInfo = new SimpleAuthenticationInfo(user, //用户DigestUtils.md5Hex(user.getPassword()),getName() //realm name);return authenticationInfo;}}}
运行
创建数据库, 然后修改数据库连接相关信息。
启动 SpringBoot 类的main方法
访问: http://localhost:8080/manage-demo
账号: admin 密码: 654321
SpringBoot后台管理系统框架相关推荐
- vue + element ui 的后台管理系统框架_从零开始搭建 VUE + Element UI后台管理系统框架...
点击右上方红色按钮关注"web秀",让你真正秀起来 前言 后台管理系统前端框架,现在很流行的形式都是,上方和左侧都是导航菜单,中间是具体的内容.比如阿里云.七牛云.头条号.百家号等 ...
- 【Vue 快速入门】从零开始搭建 VUE + Element UI后台管理系统框架
[Vue 快速入门]从零开始搭建 VUE + Element UI后台管理系统框架 前言 后台管理系统前端框架,现在很流行的形式都是,上方和左侧都是导航菜单,中间是具体的内容.比如阿里云.七牛云.头条 ...
- 后台管理系统框架bootstrap中文版
简介: 后台管理系统框架bootstrap中文版 网盘下载地址: http://kekewl.cc/8TLdhidu7gi0 图片:
- 【博主推荐】html后台管理系统框架(附源码)
html后台管理系统框架(附源码) 提示:内含有九套系统框架静态源码,包括列表,表单,曲线图,地图,报表,统计,弹框,加载等所有日常应用:不同的风格,炫酷的界面,可以直接嵌入自己的项目,并使用. 框架 ...
- web常用通用组件+Axure后台管理系统框架模板+大屏数据可视化元件库+智慧社区管理系统大屏+图表组件+表单组合+智慧数据看板+通用大屏图表原件库+电脑端常用组件
作品介绍:web常用通用组件+Axure后台管理系统框架模板+大屏数据可视化元件库+智慧社区管理系统大屏+图表组件+表单组合+智慧数据看板+通用大屏图表原件库+电脑端常用组件 Axure原型演示及下载 ...
- 后台管理系统框架搭建 | CRUD实现 | MP代码生成器 | Swagger2在线文档
day01 微信商城后台管理系统框架搭建 | CRUD实现 | MP代码生成器 | Swagger2在线文档 创建项目 项目名含大写字母会报异常 啥都不选 之后点完成 根项目的pom依赖如下,部分依赖 ...
- springboot 后台管理系统源码
项目介绍 一款 Java 语言基于 SpringBoot2.x.Layui.Thymeleaf.MybatisPlus.Shiro.MySQL等框架精心打造的一款模块化.插件化.高性能的前后端分离架构 ...
- 开源一套后台管理系统框架,远离996
前言 作为一个程序员,最苦逼的就是老板随口就给你提的需求:"小田啊,这几天你给我弄一个管理系统给客户用". 老板的一句话总是害得我们天天加班,更可怕的是,每次开个新项目,总是要从 ...
- 强大,10k+点赞的 SpringBoot 后台管理系统竟然出了详细教程!
其实项目网上有很多了,但是教程比较详细的没多少,今天分享的项目从安装部署到代码具体功能都有很详细都说明 eladmin 是一款基于 Spring Boot 2.1.0 . Jpa. Spring Se ...
最新文章
- react: menuService
- flask静态html
- OpenCV展开二维相位图
- Linux系统下按了Ctrl+s锁定屏幕后怎么办?
- 动画性能优化-requestAnimationFrame、GPU等
- 阿里云上JDK安全证书的实际位置
- 安卓图片处理全解:获取视频的缩略图
- NSGA-Ⅱ算法原理
- 软件评测师32小时-第一小时 软件测试概论
- centos7 部署安装SRS流媒体服务器
- 人工智能兴起的条件_跟我说规矩。 AI受虐狂的兴起
- 华科_图形学笔记_09_奇妙的真实感_片元着色01_01
- python编程长方形面积公式_求长方形面积-题解(Java代码)
- java stdin怎么用_如何用Java编写ssh的stdin?
- A Comparative Analysis of Deep Learning Approaches for Network Intrusion Detection Systems (N-IDSs)
- microLED可能在智能手机市场取代OLED
- 炎热夏季 本本散热板必不可少【lpxt】
- 职场中的服务 —— 满足心理诉求
- 计算机二级是win7,计算机二级等考宝典
- 计算机弹音乐百度百科,音乐术语