Add configurable group names for roles (#17)

This commit is contained in:
Christiaan Goossens
2025-01-05 22:24:48 +01:00
committed by GitHub
parent 2131fe5d36
commit 00da053f50
8 changed files with 59 additions and 12 deletions

View File

@@ -52,5 +52,15 @@ class OIDCCallbackView(HomeAssistantView):
)
return web.Response(text=view_html, content_type="text/html")
if user_details.get("role") == "invalid":
view_html = await get_view(
"error",
{
"error": "User is not in the correct group to access Home Assistant, "
+ "contact your administrator!",
},
)
return web.Response(text=view_html, content_type="text/html")
code = await self.oidc_provider.async_save_user_info(user_details)
return web.HTTPFound(get_url("/auth/oidc/finish?code=" + code))

View File

@@ -46,9 +46,9 @@ class OIDCFinishView(HomeAssistantView):
# Set a cookie to enable autologin on only the specific path used
# for the POST request, with all strict parameters set
# This cookie should not be read by any Javascript or any other paths.
# It can be really short lifetime as we redirect immediately (15 seconds)
# It can be really short lifetime as we redirect immediately (5 seconds)
"set-cookie": "auth_oidc_code="
+ code
+ "; Path=/auth/login_flow; SameSite=Strict; HttpOnly; Max-Age=15",
+ "; Path=/auth/login_flow; SameSite=Strict; HttpOnly; Max-Age=5",
},
)