# oauth-security **Repository Path**: rogchen/oauth-security ## Basic Information - **Project Name**: oauth-security - **Description**: oauth-security - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2019-11-04 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README 目前有分支:master jsonlogin interceptor 使用接口登录查看jsonlogin,用户前后端分离,也可以form登录。 使用interceptor可以用于自定义权限校验。 ## 权限说明 > permitAll() 不需要登录,所有人都可以访问,永远返回true > denyAll() 永远返回false,任何情况下都不能访问 > anonymous() 当前用户是anonymous时返回true, 即当前用户没有登录,属于匿名用户 > authenticated() 当前用户不是anonymous时返回true,可以是用户登录的或者使用记住我的都是认证的rememberMe > fullyAuthenticated() 当前用户既不是anonymous也不是rememberMe时返回true,即是通过登录来认证的 > hasRole(String role) 必须有指定权限才可以访问, Spring Security 会自动对参数值增加一个前缀ROLE_,即如果参数传admin,那么最终会变成"ROLE_admin" > hasAnyRole(String… roles) 拥有任意一个角色权限就可以访问 > hasAuthority(String authority) 拥有指定的权限时返回true,对于判断Authority的Spring Security会直接判断,不会对参数拼接前缀 > hasAnyAuthority(String… authorities) 拥有任意一个权限就可以访问 > hasIpAddress(String ipaddressExpression) 请求发来的ip地址匹配时返回true > access(String attribute) attribute可以是其它表达式,也可以通过and 将其它多个表达式连接在一起,如access("hasRole('ROLE_USER') and hasRole('ROLE_SUPER')"),权限表达式也可以自定义,然后通过access来配置