查询 Sling 自定义登录模块
Query on Sling Custom login module
我创建了自定义身份验证流程以使用外部提供商进行身份验证。根据我的理解,这是执行流程。
CustomAuthenticationHandler
(扩展 DefaultAuthenticationFeedbackHandler
并实现 AuthenticationHandler
、AuthenticationFeedbackHandler
):这会提取凭据并使用 JAAS 配置调用适当的登录模块。
- CustomLoginModule(扩展
AbstractLoginModule
)。这会调用身份提供者,选择性地分配其他组。
- CustomIdentityProvider(实施
ExternalIdentityProvider
):这是通过调用我的外部提供商的 auth API 进行身份验证的地方。
身份验证工作正常,我是说
1 > 2 > 3 工作正常,我可以调用 API 并验证用户。
我在 (3) 中从 API 获取用户信息,并通过 CustomUser(扩展 ExtenalUser
)将其传递给 (2)。
我的问题是我无法将用户信息从 (2) 传递到 (1)。我在进一步处理请求时需要此信息,以在 UI.
上显示
如何将此数据从 (2) 传递到 (1)?
到目前为止我尝试了什么?
我创建了一个 AuthInfo 对象并调用了 LoginModule 的 setInfoInfo 对象 class。它不工作。 None 我在 authInfo 中设置的自定义参数在
中可用
public boolean authenticationSucceeded(HttpServletRequest request,
HttpServletResponse response, AuthenticationInfo authInfo)
我在 CustomAuthenticationHandler
class 中改写了。如何在 CustomAuthenticationHandler
中获取我的自定义参数?
我认为您不需要 2 和 3。
在 extractCredentials 方法中,您可以调用 API 进行身份验证,并调用 authenticationSucceeded 方法将用户分配给组。
如果您想使用自定义参数,那么您需要在自定义 post 身份验证 class.
中实现 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
}
}
我创建了自定义身份验证流程以使用外部提供商进行身份验证。根据我的理解,这是执行流程。
CustomAuthenticationHandler
(扩展DefaultAuthenticationFeedbackHandler
并实现AuthenticationHandler
、AuthenticationFeedbackHandler
):这会提取凭据并使用 JAAS 配置调用适当的登录模块。- CustomLoginModule(扩展
AbstractLoginModule
)。这会调用身份提供者,选择性地分配其他组。 - CustomIdentityProvider(实施
ExternalIdentityProvider
):这是通过调用我的外部提供商的 auth API 进行身份验证的地方。
身份验证工作正常,我是说
1 > 2 > 3 工作正常,我可以调用 API 并验证用户。
我在 (3) 中从 API 获取用户信息,并通过 CustomUser(扩展 ExtenalUser
)将其传递给 (2)。
我的问题是我无法将用户信息从 (2) 传递到 (1)。我在进一步处理请求时需要此信息,以在 UI.
上显示如何将此数据从 (2) 传递到 (1)?
到目前为止我尝试了什么?
我创建了一个 AuthInfo 对象并调用了 LoginModule 的 setInfoInfo 对象 class。它不工作。 None 我在 authInfo 中设置的自定义参数在
中可用public boolean authenticationSucceeded(HttpServletRequest request,
HttpServletResponse response, AuthenticationInfo authInfo)
我在 CustomAuthenticationHandler
class 中改写了。如何在 CustomAuthenticationHandler
中获取我的自定义参数?
我认为您不需要 2 和 3。 在 extractCredentials 方法中,您可以调用 API 进行身份验证,并调用 authenticationSucceeded 方法将用户分配给组。
如果您想使用自定义参数,那么您需要在自定义 post 身份验证 class.
中实现 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
}
}