【发布时间】:2020-06-25 17:56:33
【问题描述】:
我正在尝试将 spring-boot-admin 与我的公司 SSO 集成,spring-boot-admin 是否支持 sso 登录?我找不到有关它的文档。
【问题讨论】:
标签: single-sign-on spring-boot-admin
我正在尝试将 spring-boot-admin 与我的公司 SSO 集成,spring-boot-admin 是否支持 sso 登录?我找不到有关它的文档。
【问题讨论】:
标签: single-sign-on spring-boot-admin
我让它工作了。实施步骤:
@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");
}
}
【讨论】: