【问题标题】:CAS SSO building a custom authentication handlerCAS SSO 构建自定义身份验证处理程序
【发布时间】:2020-11-13 13:13:26
【问题描述】:

我的工作区中有两组不同的人。 正式员工的 ID 以s 开头,后跟一系列数字。例如s123456789。 非正规工作人员的身份证号码全为数字。例如81234567.

普通员工将通过 LDAP 服务器进行身份验证。非常规员工将通过 RESTful api 进行身份验证。

我想添加一个实现上述策略的服务。

它将首先检查 ID 是否以 s 开头,如果是,则使用 LDAP 进行身份验证。 如果没有,请使用 rest api 进行身份验证。

查阅了CAS官方文档,我认为只有自定义的身份验证处理程序才能做到这一点。 但是我如何开始使用 cas-overlay-template 呢?有什么方向吗?

【问题讨论】:

    标签: cas


    【解决方案1】:

    要设计自定义身份验证处理程序,可以将整体任务分类如下:

    • 设计身份验证处理程序
    public class MyAuthenticationHandler extends AbstractUsernamePasswordAuthenticationHandler {
    }
    
    • 向 CAS 身份验证引擎注册身份验证处理程序。
    public class MyAuthenticationEventExecutionPlanConfiguration
                        implements AuthenticationEventExecutionPlanConfigurer {
        @Autowired
        private CasConfigurationProperties casProperties;
    
        @Bean
        public AuthenticationHandler myAuthenticationHandler() {
            var handler = new MyAuthenticationHandler();
          
            return h;
        }
    
        @Override
        public void configureAuthenticationExecutionPlan(final AuthenticationEventExecutionPlan plan) {
          plan.registerAuthenticationHandler(myAuthenticationHandler());
        }
    }
    
    • 告诉 CAS 识别注册记录和认证配置。
    org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
       com.example.cas.MyAuthenticationEventExecutionPlanConfiguration
    

    请参阅this link 了解注释和详细信息。

    【讨论】:

      猜你喜欢
      • 2020-01-07
      • 1970-01-01
      • 1970-01-01
      • 2010-11-08
      • 1970-01-01
      • 1970-01-01
      • 2018-06-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多