【发布时间】:2021-01-19 11:14:54
【问题描述】:
Keycloak 11.0.2
- 有没有办法让
UserSessionModel分配给自定义身份验证器中的当前 SSO 会话?
我可以使用List<UserSessionModel>:
List<UserSessionModel> userSessions = context.getSession().sessions().getUserSessions(context.getRealm(), context.getUser());
但我不知道我可以使用AutheticationFlowContext 使用哪个过滤属性来过滤列表并获取当前 SSO 会话的 UserSessionModel。
现在我通过从身份验证请求 cookie KEYCLOAK_SESSION(它的最后一段)获取的 UserSessionModel.id 进行过滤。也许有一种直接的方法可以以某种方式使用AuthenticationFlowContext 来获取UserSessionModel.id?
- 我必须使用
UserSessionModel.getNote()来检索之前在同一 SSO 的另一个身份验证流程中设置的 UserSessionNotes。
直接方法不适用于我在另一个身份验证流程中设置的UserSessionNotes(但在同一个 SSO 中):
@Override
public void authenticate(AuthenticationFlowContext context) {
Map<String,String> sessionNotes = context.getAuthenticationSession().getUserSessionNotes();
// sessionNotes does not reflect notes set in another Authentication flows of the same SSO
...
}
所以,如果有人知道另一种方式来采取UserSessionNotes w/o UserSessionModel 这也是解决方案。
【问题讨论】: