Simple auth CLI script to authenticate with Keycloak with username and password.
How to use this:
- In
direct_auth.py
modify configuration, and optionallyget_meta_attributes
andlogin_hook
functions to your needs. - Place
direct_auth.py
script into Home assistant. I.e. pass it to Docker container through Volume. Remember where it is located - Merge authenticator configuration from
configuration.yml
to Home assistant config file and changecommand
to path todirect_auth.py
- Make sure that
direct_auth.py
can be executed(chmod +x direct_auth.py
) - Restart Home assistant and choose
Command Line Authentication
below main log in form.
By default script will only allow authentication of users that have home_assistant
realm role.
Aquired token from Keycloak will not be used except in get_meta_attributes
and login_hook
functions.
As such I would suggest to make expiry as quick as possible, just to be safe.
- If when trying to log in with this script Home assistant writes in logs somethings like
/path/to/direct_auth.py cannot be found
- please make sure that it can be executed.