简体   繁体   English

从Shibboleth IDP 3 MFA流中的先前身份验证中获取用户属性

[英]get user attributes from previous authn in Shibboleth IDP 3 MFA flow

I'm trying to build a two factor authentication flow for shibboleth idp 3. It's set up with the MFA flow with an initial ldap authentication and then my 2FA flow, which is based on the external authn flow. 我正在尝试为shibboleth idp 3构建一个两因素身份验证流。它是使用MFA流进行设置的,该流具有初始ldap身份验证,然后是基于外部authn流的2FA流。

How can I get user data from the previous ldap flow in my servlet? 如何从servlet中的先前ldap流获取用户数据? It seems like request.getAttribute(ExternalAuthentication.PRINCIPAL_NAME_KEY) etc. is not set yet. 似乎request.getAttribute(ExternalAuthentication.PRINCIPAL_NAME_KEY)等尚未设置。 The docs say that LDAP attributes are returned as part of the authentication process and exposed in the LDAPResponseContext . 文档说LDAP属性是作为身份验证过程的一部分返回的,并在LDAPResponseContext中公开 How can I access the context in my servlet? 如何在servlet中访问上下文?

I also tried to use an attribute-resolver to release a specific value from the AD user profile, but I was not able to find those values in my servlet. 我还尝试使用属性解析器从AD用户简要表中释放特定值,但是我无法在servlet中找到这些值。 Any ideas? 有任何想法吗?

I figured it out, maybe someone else finds it helpful: 我想通了,也许其他人发现它有帮助:

The password flow populates the c14n context with the principal name, which is enough for me. 密码流使用主体名称填充c14n上下文,对我来说足够了。 To get the principal name in a servlet: 要在servlet中获取主体名称:

protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException {
        try {
            String authenticationKey = ExternalAuthentication.startExternalAuthentication(request);

            // get userPrincipalName of previous authn
            final ProfileRequestContext profileRequestContext = ExternalAuthentication.getProfileRequestContext(authenticationKey, request);
            final SubjectCanonicalizationContext c14nContext = profileRequestContext.getSubcontext(SubjectCanonicalizationContext.class);
            if (c14nContext != null && c14nContext.getPrincipalName() != null) {
                usernameShib = c14nContext.getPrincipalName();
                //Subject subjectShib = c14nContext.getSubject();
                logger.info(usernameShib);
            }
        //...
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM