首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >spring-boot-admin支持sso吗?

spring-boot-admin支持sso吗?
EN

Stack Overflow用户
提问于 2020-06-26 01:56:34
回答 1查看 138关注 0票数 1

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

EN

回答 1

Stack Overflow用户

发布于 2020-06-26 06:06:49

我让它起作用了。实施步骤:

  1. 创建具有单点登录提供程序将调用的终结点的控制器。
  2. 在终结点中,将单点登录集成的逻辑置于成功状态,重定向至/applications
  3. On失败,引发异常

代码语言:javascript
复制
@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");
    }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62581486

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档