You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Filter that allows access to resources if the accessor is a known user, which is defined as having a known principal. This means that any user who is authenticated or remembered via a 'remember me' feature will be allowed access from this filter.
If the accessor is not a known user, then they will be redirected to the loginUrl
Requires the requesting user to be authenticated for the request to continue, and if they are not, forces the user to login via by redirecting them to the loginUrl you configure.
Shiro基础概念
备注: 对于过滤器,
user
&authc
的区别如下:user
: 参考链接authc
: 参考链接user
过滤器,只要用户已经登录过,或者是通过rememberMe的方式登录的,都允许访问;authc
过滤器,要求用户必须授权,一些重要的接口,如支付等,可以设置使用该过滤器;SpringBoot整合Shiro
1、基础整合
2、CacheManager: EhCache
Ehcache Java 本地缓存的加入,可以大大提高效率,不用每次授权都查询数据库;
3、SessionManager: Redis
PS: 使用Redis做Session管理,有个问题,就是刷新后台的一个页面,会来回调用很多次Redis,这个是有问题的,找到一些解决方法:
补充: 目前对于频繁update sesion的问题,我的处理方法如下:
1). 对于 RedisSessionDao中的doUpdate,不做任何处理;
2). 使用SpringBoot的拦截器,拦截所有请求,并且判断当前用户是否登录,如果已经登录,则手动刷新Session(Redis中对应的Key增加有效时间),这样就可以大大减少Shiro频繁更新session的问题了;
4、Shiro-Thymeleaf标签
5、自定义错误页面
整合Shiro之后,访问错误资源的时候,默认的错误页面如下:
SpringBoot可以自定义配置错误页面,错误页面目录结构需要符合下面结构:
同时,SpringBoot需要配置下面的Bean:
具体,参考下面链接:
SpringBoot: custom-error-pages
Spring Boot and custom 404 error page
The text was updated successfully, but these errors were encountered: