SpringBoot 与Shirofilter

shiro讲解之 Shiro Filter shiro讲解之 Shiro Filter本章节将详细说明Shiro Filter。概念 什么是Shiro FilterShiro 提供了与 Web 集成的支持,其通过一个ShiroFilter 入口来拦截需要安全控制的URL,然后进行相应的控制。 ShiroFilter 类似于如 Strut2/SpringMVC 这种web 框架的前端控制器,是安全控制的入口点,其负责读取配置(如ini 配置文件 阅读详情

 

Shiro 一段时间没用,好多东西忘了,今天自定义Filter 注册到Shiro中的时候发现了几个问题:

1.这个Filter会执行2次 

2.受Shiro管理的filter 无法使用Spring 的bean

所以干脆直接debug源码一探究竟:

先声明一点,我们在配置中通常都是通过ShiroFilterFactoryBean来配置的

public class ShiroFilterFactoryBean implements FactoryBean, BeanPostProcessor


 并且我们能够发现他还实现了BeanPostProcessor接口,是个后置处理器,也就意味着他的加载是早与Bean的,同时也说明了Shiro的加载优先于Bean

 

  public Object getObject() throws Exception {
        if (instance == null) {
            instance = createInstance();
        }
        return instance;
    }
通过createInstance()生成具体的Shiro
 protected AbstractShiroFilter createInstance() throws Exception {

        log.debug("Creating Shiro Filter instance.");

        SecurityManager securityManager = getSecurityManager();
        if (securityManager == null) {
            String msg = "SecurityManager property must be set.";
            throw new BeanInitializationException(msg);
        }

        if (!(securityManager instanceof WebSecurityManager)) {
            String msg = "The security manager does not implement the WebSecurityManager interface.";
            throw new BeanInitializationException(msg);
        }

        FilterChainManager manager = createFilterChainManager();

        //Expose the constructed FilterChainManager by first wrapping it in a
        // FilterChainResolver implementation. The AbstractShiroFilter implementations
        // do not know about FilterChainManagers - only resolvers:
        PathMatchingFilterChainResolver chainResolver = new PathMatchingFilterChainResolver();
        chainResolver.setFilterChainManager(manager);

        //Now create a concrete ShiroFilter instance and apply the acquired SecurityManager and built
        //FilterChainResolver.  It doesn't matter that the instance is an anonymous inner class
        //here - we're just using it because it is a concrete AbstractShiroFilter instance that accepts
        //injection of the SecurityManager and FilterChainResolver:
        return new SpringShiroFilter((WebSecurityManager) securityManager, chainResolver);
    }

1.先绑定SecurityManager,如果是web环境下则匹配是否是instanceof WebSecurityManager

 2.创建FilterChain ,Shiro的过滤器链,如下所示

protected FilterChainManager createFilterChainManager() {

        DefaultFilterChainManager manager = new DefaultFilterChainManager();
        Map<String, Filter> defaultFilters = manager.getFilters();
        同时我们从代码中也能看出,Shiro率先配置Shiro自带的默认的Filter
        for (Filter filter : defaultFilters.values()) {
            applyGlobalPropertiesIfNecessary(filter);
        }
    
       然后配置我们在配置文件中自定义的Filter
        Map<String, Filter> filters = getFilters();
        if (!CollectionUtils.isEmpty(filters)) {
            for (Map.Entry<String, Filter> entry : filters.entrySet()) {
                String name = entry.getKey();
                Filter filter = entry.getValue();
                applyGlobalPropertiesIfNecessary(filter);
                if (filter instanceof Nameable) {
                    ((Nameable) filter).setName(name);
                }
                添加,内部会进行是否有判断,然后设置
                manager.addFilter(name, filter, false);
            }
        }

        为这些filter配置动态URL,与我们具体原先的具体配置有关
        Map<String, String> chains = getFilterChainDefinitionMap();
        if (!CollectionUtils.isEmpty(chains)) {
            for (Map.Entry<String, String> entry : chains.entrySet()) {
                String url = entry.getKey();
                String chainDefinition = entry.getValue();
                manager.createChain(url, chainDefinition);
            }
        }

        return manager;
    }

制此shiro的过滤器链是创建成功了

下一步添加到FileterChainResolver中去,你配置了过滤器链总要有人调用处理吧

createInstance()至此结束,接下来的就是Spring 容器加载Bean的过程了,想了解的可以看下我的这篇文章,有点简陋,但是应该也看得懂

ok,我们需要重现bug了:浏览器访问filter拦截的url:

这是filter的执行流程前置:有点拗口,我编的因为

@Override
	protected void doFilterInternal(
			HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
			throws ServletException, IOException {
        
		ServletRequestAttributes attributes = new ServletRequestAttributes(request, response);
        初始化绑定上下文,不多说了
		initContextHolders(request, attributes);

		try {
        这是核心方法
			filterChain.doFilter(request, response);
		}
		finally {
			resetContextHolders();
			if (logger.isDebugEnabled()) {
				logger.debug("Cleared thread-bound request context: " + request);
			}
			attributes.requestCompleted();
		}
	}

进入的第一个方法是ApplicationFilterChain的

@Override
    public void doFilter(ServletRequest request, ServletResponse response)
        throws IOException, ServletException {
        字面翻译就行了,是否安全,返回的是系统的SecurityManager不是Shiro的,至于为何是null我
    未深入debug,执行的是else中的方法
        if( Globals.IS_SECURITY_ENABLED ) {
            final ServletRequest req = request;
            final ServletResponse res = response;
            try {
                 
                java.security.AccessController.doPrivileged(
                    new java.security.PrivilegedExceptionAction<Void>() {
                        @Override
                        public Void run()
                            throws ServletException, IOException {
                            internalDoFilter(req,res);
                            return null;
                        }
                    }
                );
            } catch( PrivilegedActionException pe) {
                Exception e = pe.getException();
                if (e instanceof ServletException)
                    throw (ServletException) e;
                else if (e instanceof IOException)
                    throw (IOException) e;
                else if (e instanceof RuntimeException)
                    throw (RuntimeException) e;
                else
                    throw new ServletException(e.getMessage(), e);
            }
        } else {
            执行的是这个方法
            internalDoFilter(request,response);
        }
    }

internalDoFilter方法,这才是内部的onion: 注意此处的filters ,我们可以查看属性

可以看出有AuthFilter 和shiroFilter,注意shiroFIlter我们在上面得知内部也配置了一个authFIlter(这是我自定义的一个filter),所以最终会执行两次,这跟SpringBoot的机制有关,SpringBoot会自动将实现了Filter接口的Bean收集到WebFilter中,这就导致了自定义Filter和ShiroFilter同级了,也就是说相当于注册了相同的bean2次 ,ok 那第一个问题解决了,去除@Bean 的注册即可,采用new的方式

 private void internalDoFilter(ServletRequest request,
                                  ServletResponse response)
        throws IOException, ServletException {

      
      pos代表当前坐标,有一个filter的数组,这个意味着是否传递下去给下一个filter调用
        if (pos < n) {
          获取filterConfig的配置
            ApplicationFilterConfig filterConfig = filters[pos++];
            try {
                获取filter
                Filter filter = filterConfig.getFilter();
                
                if (request.isAsyncSupported() && "false".equalsIgnoreCase(
                        filterConfig.getFilterDef().getAsyncSupported())) {
                    request.setAttribute(Globals.ASYNC_SUPPORTED_ATTR, Boolean.FALSE);
                }
                
                if( Globals.IS_SECURITY_ENABLED ) {
                    final ServletRequest req = request;
                    final ServletResponse res = response;
                    Principal principal =
                        ((HttpServletRequest) req).getUserPrincipal();

                    Object[] args = new Object[]{req, res, this};
                    SecurityUtil.doAsPrivilege ("doFilter", filter, classType, args, principal);
                } else {
                    进入对应的filter处理中
                    filter.doFilter(request, response, this);
                }
            } catch (IOException | ServletException | RuntimeException e) {
                throw e;
            } catch (Throwable e) {
                e = ExceptionUtils.unwrapInvocationTargetException(e);
                ExceptionUtils.handleThrowable(e);
                throw new ServletException(sm.getString("filterChain.filter"), e);
            }
            return;
        }

        
        //filter 结束了,ok servlet它lei了
        try {
            if (ApplicationDispatcher.WRAP_SAME_OBJECT) {
                lastServicedRequest.set(request);
                lastServicedResponse.set(response);
            }

            if (request.isAsyncSupported() && !servletSupportsAsync) {
                request.setAttribute(Globals.ASYNC_SUPPORTED_ATTR,
                        Boolean.FALSE);
            }
            // Use potentially wrapped request from this point
            if ((request instanceof HttpServletRequest) &&
                    (response instanceof HttpServletResponse) &&
                    Globals.IS_SECURITY_ENABLED ) {
                final ServletRequest req = request;
                final ServletResponse res = response;
                Principal principal =
                    ((HttpServletRequest) req).getUserPrincipal();
                Object[] args = new Object[]{req, res};
                SecurityUtil.doAsPrivilege("service",
                                           servlet,
                                           classTypeUsedInService,
                                           args,
                                           principal);
            } else {
                servlet.service(request, response);
            }
        } catch (IOException | ServletException | RuntimeException e) {
            throw e;
        } catch (Throwable e) {
            e = ExceptionUtils.unwrapInvocationTargetException(e);
            ExceptionUtils.handleThrowable(e);
            throw new ServletException(sm.getString("filterChain.servlet"), e);
        } finally {
            if (ApplicationDispatcher.WRAP_SAME_OBJECT) {
                lastServicedRequest.set(null);
                lastServicedResponse.set(null);
            }
        }
    }

然后呢它会到AbstractShiroFilter chain中

protected void doFilterInternal(ServletRequest servletRequest, ServletResponse servletResponse, final FilterChain chain)
            throws ServletException, IOException {
        
         提前声明异常,之所以前置声明是因为要根据不同的Error采取不同措施
        Throwable t = null;

        try {
            准备阶段
            final ServletRequest request = prepareServletRequest(servletRequest, servletResponse, chain);
            final ServletResponse response = prepareServletResponse(request, servletResponse, chain);

            final Subject subject = createSubject(request, response);
            

            subject.execute(new Callable() {
                public Object call() throws Exception {
                    字面翻译即可
                    updateSessionLastAccessTime(request, response);
                    这是核心方法
                    executeChain(request, response, chain);
                    return null;
                }
            });
        } catch (ExecutionException ex) {
            t = ex.getCause();
        } catch (Throwable throwable) {
            t = throwable;
        }

        if (t != null) {
            if (t instanceof ServletException) {
                throw (ServletException) t;
            }
            if (t instanceof IOException) {
                throw (IOException) t;
            }
            //otherwise it's not one of the two exceptions expected by the filter method signature - wrap it in one:
            String msg = "Filtered request failed.";
            throw new ServletException(msg, t);
        }
    }

subject.execute核心方法如下:

 protected void executeChain(ServletRequest request, ServletResponse response, FilterChain origChain)
            throws IOException, ServletException {
        FilterChain chain = getExecutionChain(request, response, origChain);
        chain.doFilter(request, response);
    }

//获取过滤器链
protected FilterChain getExecutionChain(ServletRequest request, ServletResponse response, FilterChain origChain) {
        FilterChain chain = origChain;
        获取过滤器处理器
        FilterChainResolver resolver = getFilterChainResolver();
        if (resolver == null) {
            log.debug("No FilterChainResolver configured.  Returning original FilterChain.");
            return origChain;
        }
        
        这个方法解释在下面
        FilterChain resolved = resolver.getChain(request, response, origChain);

        if (resolved != null) {
            log.trace("Resolved a configured FilterChain for the current request.");
            chain = resolved;
        } else {
            log.trace("No FilterChain configured for the current request.  Using the default.");
        }

        return chain;
    }





public FilterChain getChain(ServletRequest request, ServletResponse response, FilterChain originalChain) {

        FilterChainManager filterChainManager = getFilterChainManager();
        if (!filterChainManager.hasChains()) {
            return null;
        }
        获取访问的url路径
        String requestURI = getPathWithinApplication(request);


        循环遍历匹配是否符合要拦截的url
        for (String pathPattern : filterChainManager.getChainNames()) {

  
            if (pathMatches(pathPattern, requestURI)) {
                if (log.isTraceEnabled()) {
                    log.trace("Matched path pattern [" + pathPattern + "] for requestURI [" + requestURI + "].  " +
                            "Utilizing corresponding filter chain...");
                }
                
                return filterChainManager.proxy(originalChain, pathPattern);

                内部有个挺好的idea:,这个方法不是这个重入函数里的
                  public FilterChain proxy(FilterChain orig) {
                        return new ProxiedFilterChain(orig, this);
                    }
                调用的同时生成一个新的代理Chain,从而继续代理
            }
        }

        return null;
    }
        
    


接下来就是具体的doFilter方法:这是属于ProxyFilterChain对象的方法,在这里Shiro将内部配置的bean一个一个都循环遍历下去,当然前提是要符合拦截要求

public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
        if (this.filters == null || this.filters.size() == this.index) {
            //we've reached the end of the wrapped chain, so invoke the original one:
            if (log.isTraceEnabled()) {
                log.trace("Invoking original filter chain.");
            }
            this.orig.doFilter(request, response);
        } else {
            if (log.isTraceEnabled()) {
                log.trace("Invoking wrapped filter at index [" + this.index + "]");
            }
            this.filters.get(this.index++).doFilter(request, response, this);
        }
    }

OK, 这就是差不多是过滤器链的流程了

 

 

至于第二个bug的解决方式有以下几种:

 第一种方法:.耦合度较高的一种:通过构造函数来注入: 如 A(IServiceB b)  然后在ShiroFactoryBean中添加属性参数 (IServiceB b)即可

第二种方法:.通过添加一个util来处理:

@Component
public class ApplicationContextUtil implements ApplicationContextAware
{
	private static ApplicationContext applicationContext;
	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
	{
		if (null != applicationContext)
		{
			ApplicationContextUtil.applicationContext = applicationContext;
		} else
		{
			throw new RuntimeException("ApplicationContext配置为空");
		}
	}
	public static ApplicationContext getApplicationContext()
	{
		return ApplicationContextUtil.applicationContext;
	}
}

然后在doFilter方法中通过 :

	if(null==loadBalancerClient)
		{
			this.loadBalancerClient = ApplicationContextUtil.getApplicationContext().getBean(LoadBalancerClient.class);
		}
		if(null==tmallAdminConfigProperty)
		{
			this.tmallAdminConfigProperty = ApplicationContextUtil.getApplicationContext()
					.getBean(TmallAdminConfigProperty.class);
		}

进行调用,或许有人会说在init中初始化,这是不行的哦,因为init方法并不会执行,当然或许有人想通过@PostConsturct初始化,但是注意这个加载完毕的时候那个bean还没初始化呢,不过可以这个也实现ApplicationContext接口,这是可以的,但是做不到通用

第三种方法:可以算是最快捷方便的吧,将自定义的Filter注册为Bean,是的,注册为Bean,然后借助SpringBoot提供的FilterRegistrationBean<T> 这个类:禁止这个filter ,只让Shiro管理即可:代码如下:

	@Bean
	public AuthFilter authFilter()
	{
		return new AuthFilter();
	}
	@Bean
	public FilterRegistrationBean<Filter>filterReg()
	{
		FilterRegistrationBean<Filter>filterRegistrationBean=new FilterRegistrationBean<>();
		filterRegistrationBean.setFilter(authFilter());
		filterRegistrationBean.setEnabled(false);
		return filterRegistrationBean;
	}

并且这个方式可以使得这个Filter正常的通过@Autowired 注入Bean了

springboot整合shiro shiro认证授权 阅读详情

相关推荐

springboot 整合 shiro 之 shiroFilter 异常抛出问题

今天在测试shiro的时候发现 shiro 的AuthenticationException 异常无法被 统一异常处理类处理 这是统一异常处理 这里无法处理 在 MyRealm 当中的异常 为啥呢 ? 原因 : 我在这里捕获到了我想要的异常 是 shiro 整合完 jwt 之后的过滤器BasicHttpAuthenticationFilter 这是他的继承链...

qq_36465337的博客 3873

shiro基础(一)shiroFilter

一、功能简介 shiro是java的一个安全(权限)框架,不仅可以用于javaSE环境,还可以用于javaEE环境。shiro可以完成认证、授权、加密、会话管理、缓存等功能。 Authentication:身份认证/登录。 Authorization:授权,即权限验证。 Session Manager:会话管理 Crpytography:加密 Web Support:Web集成 Re...

qq_34573549的博客 2562

使用Docker部署Spring-Boot项目,springBoot集成shiros

集成shiro1.4.0shiro-web1.4.0shiro-core1.4.0引入log4jMySQL 连接驱动依赖mysql8.0.13druid1.1.9引入servlet4.0.1provided配置热部署添加热部署truetrue热部署配置fork:如果没有该项配置,整个devtools不会起作用true2.1 编写自己定义规则,即编写自己的 realm@Autowired@Override。

2401_83641098的博客 1134

shiro Filter--拦截器

一 shiro自带的filter:下面主要叙述顺序是 NameableFilter-》OncePerRequestFilter-》AdviceFilter-》PathMatchingFilter-》AuthenticationFilter(AuthenticatingFilter)-》FromAuthenticationFilter ①NameableFilter有一个name属性,定...

weixin_30530523的博客 881

【OCCT】第3讲 OpenCasCade&VTK实现三维建模Demo

本文分享OpenCasCade&VTK共同实现三维建模Demo,希望对各位小伙伴有所帮助!1. 新建Visual Studio工程新建空项目添加main.cpp添加main函数2. 配置OpenCasCade & VTK 库配置包含路径:配置库文件:添加链接库:添加运行环境:注意:VTK库的版本要与编译OpenCasCade库时选择的版本一致,否则会出错!

qq_40041064的博客 781

轻量级NAS的隐秘战场:比特米盒CumeBox2与CasaOS的生态融合实践

本文探讨了比特米盒CumeBox2轻量级NAS设备与CasaOS操作系统的生态融合实践。通过硬件选型、系统部署、性能优化和应用场景分析,展示了如何将CumeBox2与CasaOS深度整合,打造经济实用的家庭数据管理中心,特别适合入门级用户和小型办公环境。

rl6adventurer的博客 895

shiro中的过滤器

当我们需要使用 spring 中的过滤器时,通常通过继承 filter 接口或者使用@Webfilter注解实现。shiro中过滤器实现也是通过实现filter接口实现的,shiro中整个filter类结构如下图所示,最顶层的AbstractFilter 实现了filter接口。在DefaultFilter 枚举类中列出了shiro中常用的filter这个类重写了dofilter方法,用来保证每个请求只会被一个filter过滤一次,不会重复过滤 如果当前filter没有执行过过滤,默认会进入第二个if(那两

boker123的博客 2676

高分创新点!Mamba+CNN结合,发顶会首选!

研究摘要 近期视觉领域涌现CNN与Mamba的融合架构,通过双分支设计互补优势。ConvMamba结合CNN的局部特征提取与Mamba的全局建模能力,在ImageNet分类任务中实现90.2%准确率,推理速度提升1.8倍。医学图像方向,PGM-UNet引入提示引导残差Mamba模块,结合多尺度空洞卷积与KANs,显著提升分割精度;遥感领域CM-UNet通过CSMamba块与多尺度注意力聚合模块,有效捕捉长距离依赖。这些工作表明,跨模态轻量化融合与注意力优化是未来重要方向。

m0_73122726的博客 1013

SpringBoot项目集成ShiroFilter简单实现权限管理

Apache Shiro是一个强大且易用的Java安全框架,执行身份验证、授权、密码和会话管理 由于项目需求,自学了Shiro框架,本文记录一下所用到的技术和一些无法理解的坑。 其中Shiro框架包含了很多bean属性,这些bean是可以通过自定义的方式更加符合开发需求,开发者可以通过@Configuration注释重写ShiroConfig配置文件,来设置自己需要用到的bean,上代码 pack...

Hello World 901

模糊综合评价模型

一.引子 1.数学归纳法:同高中知识 2.秃子悖论:秃子悖论 这俩个例子都是类似于“量变引起质变”的道理,而在数学中我们把这类问题的性质叫做“模糊性”,在生活中我们也经常能遇到一些模糊的概念,比如年轻、帅、很少很多… 二.概述 模糊综合评价法是一种基于模糊数学的综合评价方法。该综合评价法根据模糊数学的隶属度理论把定性评价转化为定量评价,即用模糊数学对受到多种因素制约的事物或对象做出一个总体的评价。它具有结果清晰,系统性强的特点,能较好地解决模糊的、难以量化的问题,适合各种非确定性问题的解决。——来自百度百

The__Tyche的博客 2万+

Windows Server 2019/2022 RDS 授权实战:3步激活许可证服务器,解决120天宽限期问题

本文详细介绍了Windows Server 2019/2022 RDS授权实战,提供3步激活许可证服务器的完整解决方案,解决120天宽限期问题。涵盖远程桌面授权服务器配置、许可证激活方法及组策略设置,确保企业合规使用远程桌面服务。

weixin_32705179的博客 982

springboot集成shiro的一个demo

springboot集成shiro 1.项目结构图 2.pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/

yrgyds的博客 86

Cadence Allegro 17.4学习记录开始01-原理图Capture CIS 17.4

Orcad的学习记录

qq_31444421的博客 1万+

Shiro学习总结(SpringBoot与Shiro的整合使用)

总结SpringBoot项目中如何使用Shiro进行认证与授权。

初心不忘、始终方得 1391

基于Simulink的自适应控制(Adaptive Control)电励磁同步电动机

目录基于Simulink的自适应控制(Adaptive Control)电励磁同步电动机项目实例1. 项目背景2. 系统架构2.1 电励磁同步电动机模型2.2 三相逆变器模型2.3 自适应控制器(Adaptive Controller)2.4 系统框图3. 模型设计3.1 创建Simulink模型3.2 自适应控制(Adaptive Control)设计3.3 仿真环境搭建4. 参数优化4.1 自动调优5. 实际应用案例5.1 工业驱动系统5.2 风力发电系统6. 结论进一步优化建议需求分析电励磁同步电动机

MHD0815的博客 266

【QT/C++】事件过滤器之基于重写 eventFilter 方法的多种常见应用场景及实现

Qt事件过滤器通过重写eventFilter方法实现多种实用功能:1)鼠标事件处理(点击全选文本、禁用滚轮、悬停提示);2)键盘事件处理(输入内容限制、快捷键提交);3)焦点事件处理(自动弹出下拉框、实时验证);4)绘图事件处理(自定义控件绘制);5)窗口事件处理(防止意外关闭、尺寸限制)。事件过滤器提供非侵入式的事件处理方案,相比传统子类化方式更灵活,通过installEventFilter安装到目标控件即可实现各种交互增强功能。

yuhuasheng1997的博客 1484

shirofilter配置不拦截_Springboot Shiro Redis配置高性能缓存?

导读前文章SpringBoot Shiro 实现登录/记住我的功能SpringBoot Shiro基于Url权限拦截系统Sprngboot Shiro增查按钮显示控制、注解权限拦截本文导读通过以上三篇文章,我们已经实现springboot shiro登录,权限系统,那么你们在使用这些功能的时候,发现每次调用一条权限的时候,shiro会去查询数据库,如果一个页面有大批量权限要控制的时候,那么就需要大...

weixin_39559097的博客 552

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

SpringBoot整合Shiro

SpringBoot整合Shiro 项目初始化 新建项目,勾选MVC、thymeleaf 新建一个controller测试是否能正常跳转 搭建认证 加入shiro整合spring的包 <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-spring</artifactId> <version>1.7.0</versio

weixin_46744534的博客 140

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

实战-SpringBoot与Shiro安全框架整合实现认证以及权限管理

SpringBoot是最近比较火的变态版spring系列框架,但是本文这里不是讲解springboot相关方知识的博文,如果有兴趣,博主会抽空整理写一篇。至于Shiro的相关理论知识以及实战(SSM),博主在之前的博文有详细介绍。 1.实战-Shiro安全框架(一)认证 2.实战-Shiro安全框架(二)权限控制 要实现Shiro与SpringBoot的整合,最核心的就是要将shiro的配置...

啊杰的博客 1117

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

Shiro+springboot+mybatis(md5+salt+散列)认证与授权-01

这个小项目包含了注册与登录,使用了springboot+mybatis+shiro的技术栈;当用户在浏览器登录时发起请求时,首先这一系列的请求会被拦截器进行拦截(ShiroFilter),然后拦截器根据用户名去数据库寻找是否有相对应的user实体;如果有则返回封装到User类中(没有就用户名错误),然后比对密码是否一致;如果都通过了则认证成功;登录到主页面;然后主页面有不同的功能,不同的用户拥有不同的权限,有的能看到,有的则无法看到;然后如果不登陆直接访问主页面,会被强制跳转到登录页面;另外登录之后也可以退

Kevinnsm的博客 544

springBoot集成shiros

虽然我个人也经常自嘲,十年之后要去成为外卖专员,但实际上依靠自身的努力,是能够减少三十五岁之后的焦虑的,毕竟好的架构师并不多。架构师,是我们大部分技术人的职业目标,一名好的架构师来源于机遇(公司)、个人努力(吃得苦、肯钻研)、天分(真的热爱)的三者协作的结果,实践+机遇+努力才能助你成为优秀的架构师。如果你也想成为一名好的架构师,那或许这份Java成长笔记你需要阅读阅读,希望能够对你的职业发展有所帮助。《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!

A1867350的博客 613

shirofilter配置不拦截_Spring Boot入门系列(十)如何使用拦截器,一学就会

前面介绍了Spring Boot 如何整合定时任务已经Spring Boot 如何创建异步任务,不清楚的朋友可以看看之前的文章:https://www.cnblogs.com/zhangweizhong/category/1657780.html。接下来开始讲 Spring Boot的重要功能:整合拦截器。以前我们在做mvc 项目时也使用到的是filter过滤器也就是拦截器。其实Spring Bo...

weixin_39815345的博客 1861

关于shiro与springboot的集成

关于shiro与spring boot 的集成 关于 前两个月应老师的要求做一个关于物联网后端管理平台的项目,才大二的我(准大三)对此感到瑟瑟发抖(老师咋那么看得起我呢)但我只能硬着头皮往上冲了,web端花了一周多时间大体规划好,然后我就开始敲后端。然后这里面有关于客户与管理者之间的关系,我就马上想到了shiro。去年我学过一些shiro,感受到了它的强大与方便,但那时我也只是尝试地去学学,没敲...

weixin_41997423的博客 158

springboot集成shiro_springboot 集成shiro框架,自定义过滤器不生效问题

SpringBoot+Shiro实现安全框架的时候,自定义扩展了一些Filter,并注册到ShiroFilter,但是运行的时候发现总是在ShiroFilter之前就进入了自定义Filter,结果当然是不对的。经过查看相关文档,发现其实是SpringBoot自动帮我们注册了我们的Filter,我们要的是希望Shiro来管理我们的自定义Filter。参考资料:https://docs.spring....

weixin_39964819的博客 841

springboot+shiro+jstree的资源 角色的动态权限设计

spring boot是最近比较火的微服务框架 写这篇文章的背景是 自己也在摸索shiro权限框架的设计 官方地址的话可以参考:http://docs.spring.io/spring-boot/docs/1.4.2.RELEASE/reference/htmlsingle/ spring b...

chunjiebei0262的博客 176

Spring Boot 2 + SiteMesh + Shiro 入坑记

最近入手一个项目,用的是Spring Boot 1.5 + SiteMesh + Shiro,想赶时髦升级成Spring Boot 2,于是就掉坑里了。 正常情况从login网页登录后,页面转到index。但是升级完后却报了一个常见但又很难解决的问题: org.apache.shiro.UnavailableSecurityManagerException: No SecurityManage...

elashu的专栏 1375
上一篇: log4j的配置使用
下一篇: SpringCloud feign服务熔断下的异常处理
Coder_Joker
博客等级 码龄8年 39粉丝 67原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值