我创建了一个自定义身份验证流来使用外部提供程序进行身份验证。根据我的理解,这是执行流程。
CustomAuthenticationHandler
(扩展DefaultAuthenticationFeedbackHandler
和实现AuthenticationHandler
,AuthenticationFeedbackHandler
):这会提取凭据并使用 JAAS 配置调用适当的登录模块。AbstractLoginModule
)。这会调用身份提供者,可选地分配其他组。ExternalIdentityProvider
):这是应该通过调用我的外部提供程序的 auth API 进行身份验证的地方。身份验证工作正常,我的意思是
1 > 2 > 3 工作正常,我可以调用 API 并对用户进行身份验证。
我从 (3) 中的 API 获取用户信息,并通过 CustomUser (extending ExtenalUser
)将其传递给 (2 )。
我的问题是我无法将用户信息从 (2) 传递到 (1)。我需要这些信息来进一步处理请求,以显示在 UI 上。
如何将这些数据从 (2) 传递到 (1) ?
到目前为止我尝试过什么?
我创建了一个 AuthInfo 对象并调用 LoginModule 类的 setInfoInfo 对象。它不工作。我在 authInfo 中设置的自定义参数在
public boolean authenticationSucceeded(HttpServletRequest request,
HttpServletResponse response, AuthenticationInfo authInfo)
我在CustomAuthenticationHandler
课堂上写过的。我怎样才能得到我的自定义参数CustomAuthenticationHandler
?
我认为您不需要 2 和 3。在 extractCredentials 方法中,您可以调用 API 进行身份验证和 authenticationSucceeded 方法将用户分配给组。
如果你想使用自定义参数,那么你需要在你的自定义后认证类中实现 org.apache.sling.auth.core.spi.AuthenticationInfoPostProcessor 这个接口。
您可以在 process 方法中获取 AuthInfo 对象
@Component
@Service
public class CustomAuthPostProcess implements AuthenticationInfoPostProcessor {
@Override
public void postProcess(final AuthenticationInfo authenticationInfo,
final HttpServletRequest httpServletRequest,
final HttpServletResponse httpServletResponse)
throws LoginException {
// Your logic
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句