We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Subject subject = SecurityUtils.getSubject(); subject.login(token);
@Bean(name = "securityManager") public DefaultWebSecurityManager securityManager(){ DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager(); //设置Realm securityManager.setRealm(shiroRealm()); //设置session管理器 securityManager.setSessionManager(sessionManager()); return securityManager; }
@Override protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) { //赋予角色和权限 } @Override protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException { //用户认证 }
filterChainDefinitionManager.put("/userInfo","authc"); //需要登录 filterChainDefinitionManager.put("/jobs/**","perms[JOB:CREATE]"); //需要[JOB:CREATE]权限 filterChainDefinitionManager.put("/admin/**","roles[Admin]"); //需要Admin角色
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Shiro
Shiro的几个关键概念
Realm实质上是一个安全相关的DAO:它封装了数据源的连接细节,并在需要时将相关数据提供给Shiro。当配置Shiro时,你必须至少指定一个Realm,用于认证和(或)授权。配置多个Realm是可以的,但是至少需要一个。
Realm有两个关键方法doGetAuthenticationInfo(AuthenticationToken authenticationToken)执行认证逻辑;doGetAuthorizationInfo(PrincipalCollection principalCollection)执行授权逻辑。
相关资料
The text was updated successfully, but these errors were encountered: