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

Remove administrator credentials from files once keycloak is bootstrapped #197

Conversation

hwo-wd
Copy link
Collaborator

@hwo-wd hwo-wd commented Apr 19, 2024

Since administrator credentials are only set at the very first time keycloak is started, it is not useful nor secure to have them in the /etc/sysconfig/keycloak environment vars file. This changeset modifies the behaviour during the first execution of the deployment, so that administrative credentials are applied, then purges them from configuration files and restarts the service.

To force the credentials again, delete the /etc/ansible/facts.d/keycloak file and re-execute the playbook.

Fix #190

=== original PR notes

@guidograzioli this is my take on #190:
This approach could be troublesome when the state file (/etc/sysconfig/keycloak) contains the bootstrapped mnemonicer already, but we are switching DBs where the new DB is completely empty.
But I guess this edge case would be ok favoring hiding these sensitive credentials on the long term, worst case one needs to set keycloak_quarkus_purge_admin_credentials_after_bootstrapping=True and then run the playbook once more.

Wdyt?

@hwo-wd hwo-wd force-pushed the feature/190_remove_KEYCLOAK_ADMIN_envs branch from bc12f44 to 0c99f6d Compare April 19, 2024 06:33
@guidograzioli guidograzioli added the minor_changes New parameters added to modules, or non-breaking behavior changes to existing parameters; no bugfix label Apr 19, 2024
@guidograzioli
Copy link
Member

I like the general mechanic of the changeset; let me review it thru

Copy link
Member

@guidograzioli guidograzioli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left my comments; the general gist is that I'd prefer not to have a default true parameter, but just do your implemented behaviour by default. Using a custom fact (being bootstrapped or not), we can tell users to delete it on the target node to execute the false behaviour (adding the credentials to sysconfig).

mind I am not requesting changes, just discussing!

roles/keycloak_quarkus/tasks/main.yml Outdated Show resolved Hide resolved
@hwo-wd
Copy link
Collaborator Author

hwo-wd commented Apr 19, 2024

pushed an update with custom ansible facts; @guidograzioli please review it once more; I'd squash the commits then

@guidograzioli guidograzioli self-requested a review April 19, 2024 10:18
Copy link
Member

@guidograzioli guidograzioli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -142,6 +143,15 @@ Role Variables
|`keycloak_quarkus_admin_url`| Base URL for accessing the administration console, including scheme, host, port and path | `no` |


Role custom facts
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 👍

@hwo-wd hwo-wd force-pushed the feature/190_remove_KEYCLOAK_ADMIN_envs branch 4 times, most recently from 89d8366 to f523bfd Compare April 19, 2024 11:27
@hwo-wd hwo-wd force-pushed the feature/190_remove_KEYCLOAK_ADMIN_envs branch from f523bfd to 289b476 Compare April 19, 2024 11:42
@hwo-wd
Copy link
Collaborator Author

hwo-wd commented Apr 19, 2024

LGTM

thx; linter issues resolved too -> all done

@guidograzioli guidograzioli merged commit b978e8b into ansible-middleware:main Apr 19, 2024
18 checks passed
@guidograzioli guidograzioli changed the title #190: remove keycloak_quarkus_admin_user[_pass] once keycloak is bootstrapped Remove administrator credentials from files once keycloak is bootstrapped Apr 19, 2024
@guidograzioli
Copy link
Member

Nice work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor_changes New parameters added to modules, or non-breaking behavior changes to existing parameters; no bugfix
Projects
None yet
2 participants