Open letter for improving Home Assistant’s Authentication system (OIDC, SSO) #48
Replies: 19 comments 63 replies
-
|
I have unsubscribed from notifications, if you want to reach me, please tag me in your comment. The link to this discussion has been cross-posted on the forum to inform others that the post has moved. |
Beta Was this translation helpful? Give feedback.
-
|
Thank you for putting this up for discussion for more than 2.5 years and counting. Now to a wider audience: OpenID Connect is the industry standard for deferring user identification and authentication to a third-party provider. It should be considered a de facto standard the same way username+password-based authentication is. Many efforts have been made over the last couple of years to make the implementation of OIDC in a home situation more viable. There are many choices for providers with different priorities for lean, mean, functionality and configuration options. More and more open source and selfhostable projects embrace OIDC as the way forward. It surprises me that Home Assistant still does not support this. HA does not exist in a vacuum. I would like it if I do not have to maintain separate credentials for HA if it is not required for other services I host for myself. To be frank, the official list of supported authentication methods is a bit embarrassing. That last word I write with the highest respect for HA. HA is a very mature and popular project, which is why it surprises me so much that the available authentication methods are so limited. Where is (officially supported) header-based authentication? Where is OAuth 2.0/OpenID Connect support? If security is an issue, give options with which users can secure their installations. Users can make mistakes with the proposed methods, but so can they with the currently supported authentication methods (especially trusted networks and command line). Ultimately, hardening can only happen if there are options to harden. This is not a dig towards all the wonderful work that is put in HA. I understand if priorities were somewhere else in the past. If not, HA would not be one of the few bright beacons in an otherwise very bleak IoT landscape. However, I do believe that the time has come to focus effort on authentication methods that integrate better to enhance ecosystems. After all, is that not what Home Assistant is known for? |
Beta Was this translation helpful? Give feedback.
-
|
OIDC support would let me use https://github.com/pocket-id/pocket-id for a dead simple sign in with a Passkey and be done with passwords. |
Beta Was this translation helpful? Give feedback.
-
|
Hello Christian and others. I hope home assistant can make it a core functionality of the project in the future and stay the reference software for home automation! |
Beta Was this translation helpful? Give feedback.
-
|
Yeah I now use passkeys and yubikeys via keycloak. I really would like to this feature be added. So It would be a welcomed addition to home assistant. Also along the lines of being locked out. I feel like thats on the person. I have multiple auth methods attached to my github/aws/gmails/etc for this very reason. |
Beta Was this translation helpful? Give feedback.
-
|
OIDC has become the clear industry standard for authentication — not only in enterprise environments but increasingly for home users as well. With projects like Pocket ID, strong and secure authentication is now accessible even to non-technical users. In this context, it would make sense to also modernize the authorization and permission model. For instance, Home Assistant could introduce zones or user groups — a private/family area with full access, and a guest/local area available without login. That way, guests could still control basic devices securely and independently. I genuinely believe this would elevate Home Assistant’s usability and security to a new level — and I’d even be happy to donate again to help push this feature forward. |
Beta Was this translation helpful? Give feedback.
-
|
What surprises me most is the lack of meaningful communication from the maintainers. This is by far the most upvoted feature request and all we get from the maintainers is silence. Why? Is there a new emerging technology that will render OIDC obsolete? I'm not aware of any, and none in their right mind can honestly think that the current authentication system is good enough. Is it too hard to implement OIDC? I'm not a developer, but I can only speculate that it is not since far far smaller projects implement this daily, and I do believe that Homeasssitant is far more complex to maintain than implementing OIDC. All these open letters, PRs and all the people who've over the years tried to get this done, only to be ignored by the developers makes me sad for the HomeAssistant community as well as the OpenSource community at large. |
Beta Was this translation helpful? Give feedback.
-
|
@christiaangoossens I have made a plugin that acts as a wrapper for https://github.com/oauth2-proxy/oauth2-proxy Instead of exposing the Home Assistant port to the open world, I expose the oauth2 proxy instead. I might publish it on github to see if anyone else wants to use it |
Beta Was this translation helpful? Give feedback.
-
@Westie +1 on this approach. I adopted it myself but finally rollbacked to standard password auth + MFA because of troubles with the iOS companion app. |
Beta Was this translation helpful? Give feedback.
-
|
I'd like to see Home Assistant be the OAuth/SSO Provider instead of using an online 3rd party service. |
Beta Was this translation helpful? Give feedback.
-
|
I'm glad to see this getting some discussion. I believe that not only does Home Assistant need to support the use of common identity providers/standards, but almost more importantly, integrations need to do so as table stakes. It is becoming common for manufacturers of devices and appliances to adopt identity provider sign in such as "Sign in with Apple" or Google/Microsoft/Facebook/etc to their products/services/accounts. Therefore any integration with such a product/service/account ought to be able to handle the identity provider login process. I am currently unable to set up the Toyota integration for just this reason. My only recourse would be to disassociate my vehicle from my current Toyota account, and create a new Toyota account with nonsecure simple name & password auth. As I'm sure any security expert would agree, simple auth is not significantly more secure than no auth at all. |
Beta Was this translation helpful? Give feedback.
-
|
Let's be honest here, dedicated software like Authentik, Authelia and Keycloak are probably more scrutinized as any HASS internal authentication scheme ever will be. If a user is revoked then their JWT won't help. If the user is deleted at the IdP and you have concerns then the user info endpoint can be used for validation (e.g. test it every These tools are designed to authenticate users and not being able to use an Apple/Google/Amazon/Github/etc. account is nuts in 2026. The number of web applications that attempt to implement their own authentication system is insane, it is another place where identities could be leaked or stolen from. Also WebAuthN (FIDO2) and Passkeys are a thing too, why would I want to secure my HOME with anything but the best possible software security standards. Unfathomable. |
Beta Was this translation helpful? Give feedback.
-
|
Think its crazy that SSO is not part of core yet. I need to use a passkey to sign in to Jellyfin, immich and paperless on my server, but Home assistant still is not fully compatible with authetik authellia etc This has to be one of the most requested items over the last few years |
Beta Was this translation helpful? Give feedback.
-
|
It seems to me that no one even wants to consider authorization in HA. |
Beta Was this translation helpful? Give feedback.
-
|
I’m very interested in this as I’d like to tie Home Assistant into my Pocket ID instance as another OIDC client. Pocket ID utilizes passkeys exclusively so I don’t have to worry about family members using weak passwords and it would simplify things for them by using the same SSO as my other self hosted applications. |
Beta Was this translation helpful? Give feedback.
-
|
Recently I read this discussion: Here is some more information about this from a HA maintainer: That is a healthy discussion about changing a label in HA, with many different opinions from community members, collaborators and maintainers. Sure, some might not agree with the change, but at least there is discussion and there is change. Why can such a discussion not be held about a feature request that has the highest number of votes? Why are maintainers silent about this? Is there a taboo on this subject within those circles? Who or what is fueling that taboo, if it exists? The radio silence is deafening. Tagging in some maintainers, because I have no idea whether they are actually aware of this discussion. I do this in the hope that they respond and that they can share some insights. @balloob @frenck What are the major blockers for improving the authentication system yourselves or to have it done by contributors such as @christiaangoossens? Is it a lack of interest? Fear of the unknown? A gag order? Please share your views. |
Beta Was this translation helpful? Give feedback.
-
|
Just getting into HA and the lack of native support for this topic is highly frustrating. In current times, OIDC simply means 'Sign in with Google / Apple / GitHub'. This is exactly what non-technical family members use every single day. Ironically, native OIDC would make the HA login experience significantly easier, which perfectly aligns with the 'Home Approval Factor'. Currently, HA is practically the only major open-source platform that actively refuses to support this standard. The stance that identity providers are only for 'Enterprise IT' is a complete anomaly in the self-hosting space. Please reconsider this isolated position. It's about providing a modern, secure, and simple login experience for everyone. Embracing this standard is inevitable for a modern platform – providing the opportunity sooner rather than later would be a massive win for the community. |
Beta Was this translation helpful? Give feedback.
-
|
I would love to be able to use my yubico passkey for 2FA instead of these rotating authentication codes. |
Beta Was this translation helpful? Give feedback.
-
|
It's not clear to me, when reading this discussion, which of the 3 following topics it is about, and I think a good first step is to be careful about not mixing them, as they are completely different beasts:
Those are obviously completely distinct and there is no dependency between one and another. I believe the discussion is point 3, but whichever it is, a confirmation from @christiaangoossens would be useful so we could safely ignore any unrelated comment and focus on that one. At any rate, I think all 3 points deserve their own issue in principle, so the missing 2 should be created, even if some might be closed sooner than others (I'll refrain from giving my personal opinion here and will wait until after each has its own issue). |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Note
This discussion post is a copy from home-assistant/architecture#832 and https://community.home-assistant.io/t/open-letter-for-improving-home-assistants-authentication-system-oidc-sso to the new Feature Requests system as introduced in https://community.home-assistant.io/t/heads-up-feature-requests-are-moving/903057.
Please note that this open letter is really old (written in November 2022) and may be partially outdated.
Tip
While this feature request deals with the community request for integration of these features in the Home Assistant core, a working custom integration exists at https://github.com/christiaangoossens/hass-oidc-auth.
Neither the custom integration developer or the Home Assistant team provide any guarantees on the security and functioning of that custom integration within future updates of HA.
Additionally, note that the custom integration does not actually implement all proposed solutions from this post, as most are not possible within a custom integration.
This emphasizes the need for inclusion of this feature in the core Home Assistant code, such that these solutions can be implemented!
This is a meta-analysis and open letter for authentication in Home Assistant. I have been working with the OAuth2 and OpenID Connect specifications, both integrating them on the web and in Android apps for a few years now and I would like to give my input on its implementation within the project.
In release 0.77 the "new Authentication System" was activated. From this update onwards, both the web version and the mobile apps use OAuth2 to authorize the app or the web interface to access the Home Assistant API.
For authentication, a few providers were provided within Home Assistant:
Current limitations
While this new Authentication system is a big step forward and enables nice features, such as building third-party external apps against the Home Assistant API by use of the OAuth2 authorization method to obtain a properly-scoped access token, it has a few issues. I will deal with them in their own subsections.
Additional providers within Home Assistant
There have been some PR's to include useful additional authentication providers within Home Assistant, such as:
LDAP/Active Directory authentication provider core#37645 (comment)
Update, after the initial publication of this post (home-assistant/architecture#832 and https://community.home-assistant.io/t/open-letter-for-improving-home-assistants-authentication-system-oidc-sso) more have been made, such as: home-assistant/frontend#23204
I remember also seeing some comments that maintaining these providers within the Home Assistant code would lead to possible security issues as it put a large burden on the maintainers to know the specifications, all their flaws and keep this secure.
Additional providers as plugins
With the new authentication system, it should have been easy to integrate new providers, such as LDAP and OIDC as plugins, possibly through HACS. I only know of one successful authentication plugin: https://github.com/BeryJu/hass-auth-header by BeryJu, the creator of Authentik, a project I have also followed from its Passbook early days. While the plugin itself works fine, if a header is passed, it updates the authentication screen to include a "Header auth" option which just has a button to detect the header and continue, the setup around it has problems.
Many users running Homelabs would like to tie Home Assistant into their existing SSO system, but as authentication proxies (using https://github.com/BeryJu/hass-auth-header) are the only option, proxy auth for apps using OAuth2 and/or using service workers is not the right idea.
Currently, you can find many issues and Reddit threads, such as home-assistant/android#1438, authelia/authelia#1842 (comment) and goauthentik/authentik#884 (comment), which include ideas to disable the service worker, exclude certain paths from the proxy auth or only enable proxy auth for /auth/*.
For apps implementing OAuth2 as their authorization layer, such as Home Assistant, one should have access to the login page and the static assets, as those are vital to allowing third-parties access to the API. Other applications should always be able to make an OAuth2 authorization request, without being stopped by the proxy auth first. They should however be stopped at the authentication phase right after, but as there are no OpenID Connect or LDAP plugins that integrate to that stage (like the PR's above), it is not possible to go that route right now for integrating Home Assistant with your current SSO, be it at home, or for a company.
Android Mobile app uses Webview instead of Custom Tabs
Currently, the Android Companion app uses Webview (https://github.com/home-assistant/android/blob/fa001ffc29fc1ff8bfd2f47f0628666edbe3f386/app/src/main/java/io/homeassistant/companion/android/onboarding/authentication/AuthenticationFragment.kt) for its Authentication Fragment.
The Android Webview implementation lags behind in its support of modern web standards, does not share a context with the main browser and is therefore not recommended for use with OAuth2 in the authorization-community. This also lead Google to disallow embedded webviews for OAuth2 (read this article to find out more why it's a bad idea).
Instead, you should use Custom Tabs. These tabs are part of the main browser (often Chrome) and share a session with this browser. If you are already logged in with the main browser, you will be logged into the Custom Tab as well. Additionally, as the tabs use modern Chrome, they have access to all modern web standards.
Doing this would also prevent issues like: goauthentik/authentik#3304 and BeryJu/hass-auth-header#124, where the webview does not render Authentik correctly and does not support FIDO2 Security Keys, which totally disables Authentik for some users.
Proposal
Having looked at some current identified issues, I would like to propose the following:
Home Assistant should welcome external authentication
The Home Assistant project is about connecting with many home devices and integrating as many different devices to one platform. It is not about creating the strongest authentication method. We should leave strong auth, or the option to use stronger auth, to other platforms, such as Authentik and Authelia at home, or Keycloak, Azure AD and Okta in the enterprise setting.
External SSO authentication providers allow for many benefits that will likely not be included within Home Assistant's native authentication provider, such as:
In conclusion, external SSO providers will always be better at authentication than your own solution. Embrace them, not extinguish.
Mobile Apps
The mobile apps should not assume anything about the authentication/authorization process, except that it is OAuth2, happens within a webbrowser and uses the Authorization Grant flow with PKCE (RFC 7636). This is the recommended OAuth2 flow for native clients as per RFC8252.
They should open this authorization endpoint URL (
https://YOUR_INSTALL_URL:8123/auth/authorize?......) within a Android Custom Tab on Android, the native browser or the SFSafariViewController on iOS and should expose a return URL (homeassistant://auth-callback) to call back with the authorization code within the OAuth2 process. You should then use PKCE to ensure that the app returned to did start the request and check the state.This:
Authentication Providers
Home Assistant should encourage the creation of LDAP and OIDC plugins that add authentication providers that nicely integrate within the current flow, instead of the "brute force proxy" approach which destroys many of the benefits of the OAuth2 and service worker systems within Home Assistant.
home-assistant/core#37645 and home-assistant/core#32926 should either be revived as core parts of Home Assistant, or - and I think most likely - as well-maintained separate plugins that are easy to install through HACS.
Again, embrace external authentication, not extinguish to improve security for all users.
Consequences
I want to get back to the specific reason why the PRs got declined by balloob:
You are right and it's very good that you realized this shortfall! OpenID Connect implementations in fact often have two common shortfalls (I will give the solutions later on):
Suppose that you add OIDC to an existing Home Assistant install, where all your users have 2FA, users with the same username or email from all providers are considered the same and you add a OIDC authentication provider that does not require 2FA (possibly bad config), you can circumvent the original 2FA! Well, this actually happend to CloudFlare, when they added "Signin with Apple". If you had an insecure Apple account matching the same email of a 2FA secured CloudFlare user, you could just login to their account using Apple, no questions asked.
User logout at the IdP (OIDC provider) are not propagated to the consuming app, especially if you are using refresh_tokens or long-lived access tokens. As balloob correctly identifies, the check (often) only happens on the authentication stage!
Solutions:
1st issue
When implementing OIDC/SAML in your app you do the following:
Alternatively, you could always prefix usernames with the OIDC provider name (or similar) to prevent username "collisions" entirely and always create a unique account. This however disallows for migrating from local accounts to OIDC accounts, so I would recommend the approach above.
2nd issue
First off, sensitive apps should always use short expiry access tokens, for instance, 1 hour. Native/mobile apps can then use the refresh token to get a new token, and web apps can use the prompt=none silent refresh flow to try and get a token within an iframe.
Additionally, when changing a password or disabling a user, you should revoke all of their JWT's by keeping a list of revoked JTI's (RFC 7519) and checking these on every API request. For distributed apps, this could mean keeping this list in a shared cache, such as Redis, and checking it with all API microservices.
However, we have not solved the issue of users getting disabled at the SSO provider, just for local disabling.
We actually have three solutions here:
There are specifications for logout with OpenID Connect: https://openid.net/specs/openid-connect-frontchannel-1_0.html and https://openid.net/specs/openid-connect-backchannel-1_0.html. The OpenID Connect Back-Channel logout specification solves this issue perfectly. It adds a sid field within the original id_token that can be saved by the RP (Home Assistant). Then, Home Assistant exposes an API route that allows for the OIDC provider to call it whenever the token should be revoked, including the sid within a signed JWT. After this, the exact same happens as with local disabling, we add the JTI of all issued tokens for that user onto the blacklist. Sadly, many providers do not implement this, as indicated by backchannel_logout_supported within their OpenID well-known discovery document.
Alternatively, we could show external SSO users on the user list for admins and allow disabling the accounts from there, including revoking all tokens. While this does not disable them automatically from the OIDC provider and should be used in tandem with any of the two other solutions, this does make sure that they cannot login immediately, like with local accounts.
Finally, we can use the UserInfo endpoint to do a basic check if the authentication is revoked, as detailed below:
Implementing OIDC
If you implement OIDC for authentication, you only get proof of user identity at that moment from the OIDC provider. Therefore, you can use the issued id_token to obtain identity data, such as name, email etc. You can also use the UserInfo Endpoint, which includes the same information.
You will also get an access_token and possibly a refresh_token. These should only be used for the UserInfo Endpoint.
Using the UserInfo Endpoint to check if a user is still valid
We can store these access_tokens and refresh_tokens on the backend (remember that they only have access to the openid, profile and email scopes and can thus do nothing else than UserInfo checks and are thus limited in security scope) to do a new user info request on every token refresh (refresh token / silent flow).
If a user is returned and it matches the saved OIDC user, we allow a new refresh or access token for our app to be issued and revoke the old refresh token or access tokens (as stated in the OAuth2 spec).
If the access token is expired and the refresh token cannot be used to obtain a new UserInfo Endpoint access token from the OIDC Provider, we MUST have the user re-authenticate.
Summary
This mostly solves the issue by:
However, it requires storing this IdP access/refresh token in the database.
Conclusion
While not all questions are answered with a perfect answer, as many parties do not fully implement all OIDC specs, we should not let perfect be the enemy of good. Yes, we should have warnings for users enabling SSO for Home Assistant, possibly even requiring them to install HACS, a custom OIDC plugin and then enable it within YAML. This will at least keep very novice users from doing something dangerous with badly configured OIDC providers.
However, the benefits of having external providers, with much stronger authentication than Home Assistant can ever implement within the bounds of the app (see above at Proposal), massively out way the downsides. Even SSO without proper logout is safer than users with bad passwords, leaky proxy auth configs and too extensive "trusted network" configs. With the solutions proposed and proper documentation, we can even eliminate most scenarios.
Home Assistant, a platform I trust daily to keep my home automated and controllable, deserves the option for strong SSO to be configured, such that I can rest assured that logging in is not possible without using my physical security key, while still allowing for me to quickly switch to other apps linked to my SSO config.
Definitions
If you already know these, skip this ;)
Authentication = the process of making sure the user on the other end is the user that you have in your system (confirming identity), for instance, through username & password, an external party (such as Google login) and/or through 2FA or other additional authentication methods
Authorization = the process of granting an already identified user, access rights, for instance, internally within Home Assistant to access the APIs. It can also be used the other way around, where Home Assistant requests access to data for Google Assistant, through using Googles Authorization APIs.
OAuth2 = an Authorization specification which makes it possible to give external parties (other apps) access to data from your app (in this case Home Assistant), or is implemented by other parties (such as Google) to give Home Assistant access
OpenID Connect (OIDC) = an Authentication extension to the OAuth2 specification which also gives external parties access to the "authentication"/"identity" part of the login, such that they can use
Why did I include this?
Even the Home Assistant documentation on the access token API's, uses these terms interchangeably and sometimes in the wrong context. For instance, the first sentence "This page will describe the steps required for your application to authorize against and integrate with Home Assistant instances." is correct, but the title "Authentication API" is not. However the page on "Authentication Providers" is correctly named and provides the correct definition "Authentication providers confirm the identity of users.".
In short, and throughout the open-source space, these terms are not easy. Especially since this is not the part of apps that most developers deal with a lot. We cannot blame developers or documentation writers for not being experts in authentication/authorization
Final notes
This discussion post is a port from home-assistant/architecture#832 and https://community.home-assistant.io/t/open-letter-for-improving-home-assistants-authentication-system-oidc-sso to the new Feature Requests system as introduced in https://community.home-assistant.io/t/heads-up-feature-requests-are-moving/903057. At the time of moving, it had 898 upvotes on the forum.
This letter is not a meant as a critique of the current system, just as a suggestion for improvements that might benefit the security and usability of Home Assistant in some scenario’s. I love the Home Assistant developers for their dedication to this great platform and the current apps that we already use daily. ❤️
I wrote this letter to convey my opinions and pointers on the subject of external authentication (SSO) within Home Assistant, for instance using OpenID Connect (OIDC), SAML or LDAP. If you agree that adding external authentication would be beneficial for HA, please leave an upvote and/or reply with your use-cases.
Thank you balloob for starting this project, and thanks for all maintainers and contributors for creating something that I interact with every day. This was just on my mind after trying to integrate Home Assistant with Authentik, after Immich succesfully integrated OpenID Connect as well. I was frustrated with the current tickets and the lost users, most of who do not know enough about the specification to write a full analysis and were just configuring proxy auth in many dangerous ways. Therefore, these are my 2 cents.
I would like to hear from everyone interested in this issue and I hope that we can all make Home Assistant better! I am also open to call about this or answering any comments you might have. Thank you for reading!
Beta Was this translation helpful? Give feedback.
All reactions