自定义认证

总览

Inlong Manager中使用了Apache Shiro框架实现了认证和授权等功能,Manager已经集成好了默认的实现逻辑,如果您想在Inlong Manager中实现自定义的基于Shiro的认证和授权功能,您可以按照如下的说明,进行相关功能的插件化开发。

依赖

  • 增加maven 依赖

    1. <dependency>
    2. <groupId>org.apache.inlong</groupId>
    3. <artifactId>manager-common</artifactId>
    4. <version>2.1.0-SNAPSHOT</version>
    5. </dependency>

编码

  • 实现其中关于Shiro相关模块的接口
  1. org.apache.inlong.manager.common.auth.InlongShiro
  2. public interface InlongShiro {
  3. WebSecurityManager getWebSecurityManager();
  4. AuthorizingRealm getShiroRealm();
  5. WebSessionManager getWebSessionManager();
  6. CredentialsMatcher getCredentialsMatcher();
  7. ShiroFilterFactoryBean getShiroFilter(SecurityManager securityManager);
  8. AuthorizationAttributeSourceAdvisor getAuthorizationAttributeSourceAdvisor(SecurityManager securityManager);
  9. }
  • 实现InlongShiro接口,并在”@ConditionalOnProperty”指定配置
  1. @ConditionalOnProperty(name = "type", prefix = "inlong.auth", havingValue = "Custom")
  2. @Component
  3. public class InlongShiroImpl implements InlongShiro {
  4. //todo
  5. }
  • 修改manager-web module下application.properties文件中配置
  1. inlong.auth.type=Custom