Simple auth CLI script to authenticate with Keycloak with username and password.
How to use this:
- In
direct_auth.pymodify configuration, and optionallyget_meta_attributesandlogin_hookfunctions to your needs. - Place
direct_auth.pyscript into Home assistant. I.e. pass it to Docker container through Volume. Remember where it is located - Merge authenticator configuration from
configuration.ymlto Home assistant config file and changecommandto path todirect_auth.py - Make sure that
direct_auth.pycan be executed(chmod +x direct_auth.py) - Restart Home assistant and choose
Command Line Authenticationbelow 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.