merge
This commit is contained in:
@@ -65,7 +65,6 @@ public class DispatcherServletConfig extends WebMvcConfigurerAdapter {
|
||||
@Override
|
||||
public void addViewControllers(ViewControllerRegistry registry) {
|
||||
//路由配置
|
||||
registry.addViewController("/").setViewName("login.html");
|
||||
registry.addViewController("druid").setViewName("druid/index.html");
|
||||
//重定向
|
||||
registry.addRedirectViewController("doc", "swagger-ui.html");
|
||||
|
||||
@@ -137,8 +137,8 @@ public class SysUserControl {
|
||||
@GetMapping("logout")
|
||||
public JSONObject logout(HttpServletRequest request) {
|
||||
Subject subject = SecurityUtils.getSubject();
|
||||
if (subject != null && subject.getPrincipals() != null) {
|
||||
SysUser sysUser = (SysUser) subject.getPrincipals().getPrimaryPrincipal();
|
||||
if (subject != null && subject.getPrincipal()!= null) {
|
||||
SysUser sysUser = (SysUser) subject.getPrincipal();
|
||||
if (null != sysUser) {
|
||||
SysUserLoginInOut loginInOut = new SysUserLoginInOut();
|
||||
loginInOut.setCreateTime(new Date());
|
||||
|
||||
@@ -36,19 +36,20 @@ public class MyShiroRealm extends AuthorizingRealm {
|
||||
private SysRoleService sysRoleService;
|
||||
|
||||
/**
|
||||
* 授权
|
||||
* 授权用户权限
|
||||
*
|
||||
* @param principalCollection
|
||||
* @param principals
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) {
|
||||
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
|
||||
// 获取验证的对象
|
||||
if (principalCollection == null) {
|
||||
if (principals == null) {
|
||||
throw new AuthorizationException("Principal对象不能为空");
|
||||
}
|
||||
SysUser user = (SysUser) principalCollection.fromRealm(getName()).iterator().next();
|
||||
if (user != null) {
|
||||
Object primaryPrincipal = principals.getPrimaryPrincipal();
|
||||
if (primaryPrincipal != null) {
|
||||
SysUser user = (SysUser) primaryPrincipal;
|
||||
// 权限信息对象info,用来存放查出的用户的所有的角色(role)及权限(permission)
|
||||
SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
|
||||
// 用户的角色集合
|
||||
@@ -67,7 +68,7 @@ public class MyShiroRealm extends AuthorizingRealm {
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录.认证
|
||||
* 验证用户身份
|
||||
*
|
||||
* @param authenticationToken
|
||||
* @return
|
||||
|
||||
@@ -32,7 +32,7 @@ public class ShiroConfig {
|
||||
private String sessionIdCookieName;
|
||||
|
||||
@Bean
|
||||
public ShiroFilterFactoryBean shirFilter() {
|
||||
public ShiroFilterFactoryBean shiroFilter() {
|
||||
ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
|
||||
shiroFilterFactoryBean.setSecurityManager(securityManager());
|
||||
//配置访问权限
|
||||
@@ -45,8 +45,6 @@ public class ShiroConfig {
|
||||
chains.put("/static/**", "anon");
|
||||
chains.put("/public/**", "anon");
|
||||
chains.put("/*.*", "anon");
|
||||
chains.put("/", "anon");
|
||||
chains.put("/doc", "anon");
|
||||
//验证码
|
||||
chains.put("/captcha", "anon");
|
||||
//swagger
|
||||
@@ -55,8 +53,11 @@ public class ShiroConfig {
|
||||
chains.put("/swagger-resources", "anon");
|
||||
chains.put("/configuration/ui", "anon");
|
||||
chains.put("/configuration/security", "anon");
|
||||
//
|
||||
chains.put("/doc", "anon");
|
||||
//德鲁伊数据源
|
||||
chains.put("/druid/*", "anon");
|
||||
chains.put("/druid", "anon");
|
||||
//权限认证路径
|
||||
chains.put("/**", "authc");
|
||||
shiroFilterFactoryBean.setFilterChainDefinitionMap(chains);
|
||||
return shiroFilterFactoryBean;
|
||||
|
||||
Reference in New Issue
Block a user