Hello,
I am doing an Authenticator provider based on
the SecretQuestionAuthenticator example. (Let's call it MyAuthenticator)
In the SecretQuestionAuthenticator example, in
*setCookie(AuthenticationFlowContext context)* we can get the "actual"
AuthenticatorConfigModel directly: context.getAuthenticatorConfig()
I want to use a new entry (added by the Factory, as in the example) in
which I have an URL of an external service (the key is called
"url.externalservice").
I can get the config entry it in
MyAuthenticator#action(AuthenticationFlowContext context) without problem:
AuthenticatorConfigModel config = context.getAuthenticatorConfig().
if (config != null) {
externalServiceURL =
config.getConfig().get("url.externalservice");
}
But I also need to get the entry from another place. In this case in
configuredFor(KeycloakSession session, RealmModel realm, UserModel user)
Searching a lot, reading code and trying things, I got it from realm:
realm.getAuthenticatorConfigs().get(0).getConfig().get("url.externalservice");
I also need to use it in MyAuthenticator*RequiredAction*, in
processAction(RequiredActionContext context).
But I don't have a context.getAuthenticatorConfig() in
RequiredActionContext, so I also use it as:
context.getAuthenticationSession().getRealm().getAuthenticatorConfigs().get(0).getConfig().get("url.externalservice");
But I am not sure that my "current configuration" will be always the
position 0 of the array.
We have realm.getAuthenticatorConfigByAlias()
and getAuthenticatorConfigById(), but, how do I know wich is the alias or
ID of the "current" context?
So, how can I know the "current" AuthenticatorConfig Alias or ID, or how
can I get the current AuthenticatorConfig from these places?
Thanks,
Luis Cardozo
Ciudad del Este, Paraguay