Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve loading configs #24

Open
melegiul opened this issue Jul 4, 2022 · 4 comments
Open

Improve loading configs #24

melegiul opened this issue Jul 4, 2022 · 4 comments
Labels
component/sms SMS authenticator component enhancement New feature or request

Comments

@melegiul
Copy link
Collaborator

melegiul commented Jul 4, 2022

In the moment the custom required actions assume there exists an authenticator config object with the alias "sms-2fa".
Instead of loading the config by this predefined alias it should be loaded either from the database (with arbitrary alias) or loaded from keycloaks globale settings (see #20 (comment) and following)

@melegiul melegiul added the enhancement New feature or request label Jul 4, 2022
@svenseeberg
Copy link
Member

svenseeberg commented Jul 4, 2022

It may be possible to set custom realm attributes with the kcadm.sh tool:

kcadm.sh update -r myrealm -s sms-2fa-default-api-provider=sms-2fa-foobar

if that does not work, it would be possible to set this manually in the database in the realm_attribute table, which has the following columns: name, realm_id, value. As in:

INSERT INTO realm_attribute (realm_id, name, value) VALUES ('REALM_UUID', 'sms-2fa-default-api-provider', 'sms-2fa-foobar');

@melegiul
Copy link
Collaborator Author

melegiul commented Jul 8, 2022

Each RequiredActionFactory and AuthenticatorFactory overrides this method:

@Override
    public void init(Config.Scope config) {

    }

Here it says, that this config is loaded from a file called keycloak_server.json, but I didn't tried this yet: https://github.com/keycloak/keycloak/blob/48266fa48fbd6ea4ec8d07df8e990850be6ba9a3/server-spi/src/main/java/org/keycloak/provider/ProviderFactory.java#L39

@melegiul
Copy link
Collaborator Author

melegiul commented Aug 3, 2022

Passing configs to spi providers actually works like this:

  1. Run keycloak and pass configs to CLI command e.g. bin/kc.sh start-dev --spi-required-action-mobile_number_config-code-length="6" (https://www.keycloak.org/server/configuration-provider)
  2. Read config in corresponding factory init(Config.Scope config) { config.getInt("code-length", default); }

Downside is, that we have many configs to pass.

@svenseeberg
Copy link
Member

svenseeberg commented Nov 24, 2022

Downside is, that we have many configs to pass.

I guess there must be a way to put everything into one config file? That would be a nice solution. Then we can remove the config from the single authentication flows. The current solution feels a bit hacky.

There is a discussion about configuring providers: keycloak/keycloak#10311

@svenseeberg svenseeberg added the component/sms SMS authenticator component label Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/sms SMS authenticator component enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants