我正在尝试将spring-boot-admin与公司SSO集成在一起,spring-boot-admin是否支持sso登录?我找不到有关它的文档。
答案 0 :(得分:0)
我明白了。实施步骤:
@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");
}
}