| | |
| | | package com.iailab.framework.security.config; |
| | | |
| | | import cn.hutool.extra.spring.SpringUtil; |
| | | import com.iailab.framework.security.core.aop.PreAuthenticatedAspect; |
| | | import com.iailab.framework.security.core.context.TransmittableThreadLocalSecurityContextHolderStrategy; |
| | | import com.iailab.framework.security.core.filter.TokenAuthenticationFilter; |
| | |
| | | import com.iailab.framework.web.core.handler.GlobalExceptionHandler; |
| | | import com.iailab.module.system.api.oauth2.OAuth2TokenApi; |
| | | import com.iailab.module.system.api.permission.PermissionApi; |
| | | import org.springframework.beans.factory.annotation.Qualifier; |
| | | import org.springframework.beans.factory.config.MethodInvokingFactoryBean; |
| | | import org.springframework.boot.autoconfigure.AutoConfiguration; |
| | | import org.springframework.boot.autoconfigure.AutoConfigureOrder; |
| | |
| | | @Bean |
| | | public TokenAuthenticationFilter authenticationTokenFilter(GlobalExceptionHandler globalExceptionHandler, |
| | | OAuth2TokenApi oauth2TokenApi) { |
| | | try { |
| | | OAuth2TokenApi oAuth2TokenApi = SpringUtil.getBean("aAuth2TokenApiImpl", OAuth2TokenApi.class); |
| | | if (oAuth2TokenApi != null) { |
| | | oauth2TokenApi = oAuth2TokenApi; |
| | | } |
| | | } catch (Exception ignored) {} |
| | | return new TokenAuthenticationFilter(securityProperties, globalExceptionHandler, oauth2TokenApi); |
| | | } |
| | | |
| | | @Bean("ss") // 使用 Spring Security 的缩写,方便使用 |
| | | public SecurityFrameworkService securityFrameworkService(PermissionApi permissionApi) { |
| | | try { |
| | | PermissionApi permissionApiImpl = SpringUtil.getBean("permissionApiImpl", PermissionApi.class); |
| | | if (permissionApiImpl != null) { |
| | | permissionApi = permissionApiImpl; |
| | | } |
| | | } catch (Exception ignored) {} |
| | | return new SecurityFrameworkServiceImpl(permissionApi); |
| | | } |
| | | |