feat(keycloak)!: Add admin, realm & client provisioning #444
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "keycloak-provisioning"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This changes the Keycloak role to provision the master and an additional user realm. It also creates admin accounts and OAuth clients for the user realm.
Keycloak is now bootstrapped on start.
This causes the playbook to start Keycloak with a random initial password for the admin account if it does not detect a
bootstrappedfile.This admin user is then instantly repalced with a special ansible service account, which is then used for all future provisioning.
After the bootstrap process is done, we delete the bootstrap env file and the container is retemplated as usual.
Also, we now configure the admin users after Keycloak has started:
initial_passwordsdirectoryNote: The
keycloak_useraction does not change users after they have been created, so its safe to execute even when users set their new passwords.Further, we now also enable brute force protection on the master realm and create a normal realm along with the configured OAuth OpenID-Connect clients.
We do not offer options for all config options for now and only limit ourselves to the necessary and common ones.
We can easily add more variables later on.
Additionally, we also support creating client roles, which can be useful e.g. for tools like Grafana.
At the moment, we only support creating a single custom realm.
Migration hints:
This role expects you to own a master realm and another user realm.
When migrating existing installations, we recommend the following steps.
touch bootstrappedin the keycloak directorykeycloak_realm, clients are optional and will not be deleted if none are addedd0dd5ee85d38c545ee7738c545ee777d7f5ad9537d7f5ad953cc2aebcb3eLGTM 2 nits and a suggestion :)
@ -36,0 +72,4 @@# name: "My Application"# public_client: false# standard_flow_enabled: true# direct_access_grants_enabled: falseshould we really leave this configurable? Seeing that this is the
Resource Owner Password Credentials Grantwhich is insecure and MUST NOT be used [1][1] https://www.rfc-editor.org/rfc/rfc9700.html#name-resource-owner-password-cre
edit: they are disabled in the task anyway so they should be removed from here
@ -36,0 +74,4 @@# standard_flow_enabled: true# direct_access_grants_enabled: false# service_accounts_enabled: false# implicit_flow_enabled: falsesame here the implicit flow SHOULD NOT be used [2]
[2] https://www.rfc-editor.org/rfc/rfc9700.html#name-implicit-grant
edit: they are disabled in the task anyway so they should be removed from here
@ -0,0 +58,4 @@- name: Retemplate the container file for bootstrappingansible.builtin.template:src: keycloak.container.j2dest: "/etc/containers/systemd/keycloak.container"Should we deploy this as
keycloak-bootstrap.container?that would make it exceedingly clear what this is intended to do and might be more obvious if something would go wrong.
As a side effect this would also generate to a
keycloak-bootstrap.servicefile which we can then distinguish in the journal logscc2aebcb3e965a65264fNoice :)
965a65264fd1b176f56dd1b176f56d0685527504