# GrailsShiro **Repository Path**: GntLee/GrailsShiro ## Basic Information - **Project Name**: GrailsShiro - **Description**: 本项目是基于grails3集成shiro权限管理的入门小demo,可实现基于用户、角色的权限管理,没有页面。 - **Primary Language**: Groovy - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2018-04-07 - **Last Updated**: 2020-12-18 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README #本项目集成Grails3-Shiro 项目描述: ``` 本项目是基于grails3集成shiro权限管理的入门小demo,可实现基于用户、角色的权限管理,没有页面。 ``` 开发环境: ``` | Grails Version: 3.1.5 | Groovy Version: 2.4.6 | JVM Version: 1.8.0_141 ``` 集成shiro重点: ``` //build.gradle中新增maven库 maven { url "https://dl.bintray.com/shiranr/plugins" } maven { url "https://dl.bintray.com/animator013/plugins/" } //dependencies中新增依赖: compile 'org.grails.plugins:grails-shiro:3.0.1' ``` 通过命令创建域类,控制器,realms以及页面等等 ``` shiro-quick-start ``` 项目如何运行? ``` 1、项目clone导入idea,配置好gradle并刷新 2、修改数据库配置文件grails-app/conf/application.properties 3、用户名密码在grails-app/init/BootStrap.groovy中,可自行修改 ``` # 升级说明 * 2019/01/04 新增无密登录(适用于第三方登录) #### 实现步骤 * 重写`UsernamePasswordToken`类 * 重写`HashedCredentialsMatcher`类中的`doCredentialsMatch`方法 * `grails-app/conf/spring/resources.groovy`中注入bean为`credentialMatcher`的自定义类`CustomHashedCredentialsMatcher` * `realms/ShiroDbRealm.groovy`中调用自定义类`CustomHashedCredentialsMatcher credentialMatcher` * 登录时获取`token`调用自定义类`CustomUsernamePasswordToken`