【问题标题】:Does spring-boot-admin support sso?spring-boot-admin 支持 sso 吗?
【发布时间】:2020-06-25 17:56:33
【问题描述】:

我正在尝试将 spring-boot-admin 与我的公司 SSO 集成,spring-boot-admin 是否支持 sso 登录?我找不到有关它的文档。

【问题讨论】:

    标签: single-sign-on spring-boot-admin


    【解决方案1】:

    我让它工作了。实施步骤:

    1. 使用 sso 提供程序将调用的端点创建控制器。
    2. 在端点中,放置sso集成的逻辑,
    3. 成功后,重定向到 /applications
    4. 失败时抛出异常
    @Controller
    public class SsoIntegration {
    
        // this does addition authentication stuff, like sets up the 
        // right authorities...etc
        @Autowired
        private AuthenticationProvider authenticationProvider;
    
    
        // my sso provider creates a vanity url that redirects to 
        // this endpoint and passes 2 request params using POST
        @RequestMapping(value={"/sso"}, method = {RequestMethod.POST})
        public String ssologin (
                  @RequestParam(name="param1") String param1, 
                  @RequestParam(name="param2") String param2 ) 
        {
    
            // do your sso integration logic here
            // eg...
            SsoUtil util = new SsoUtil();
            String userInfo = util.decrypt(param1, param2, ...);
    
            ...
            if (authenticationProvider.authenticate( userInfo )) {
              Authentication postAuthentication = ...// populate your successfully authenticated user
               
    
              // these next lines are the important stuff
              // 1. set the postAuthentication into the security context 
              SecurityContextHolder.getContext().setAuthentication(postAuthentication); 
    
              // 2. redirect to the applications page
              return "redirect:/applications";
            }
            
            // authentication failed, throw an exception...
            throw new RuntimeException ("Sso Authentication failed");
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-07-24
      • 1970-01-01
      • 2015-03-03
      • 2018-03-14
      • 2018-01-29
      • 1970-01-01
      • 2016-10-21
      • 2018-01-21
      相关资源
      最近更新 更多