fix: group mapping (#13)
This commit is contained in:
@@ -50,8 +50,8 @@ async def async_setup(hass: HomeAssistant, config):
|
|||||||
|
|
||||||
_LOGGER.info("Registered OIDC provider")
|
_LOGGER.info("Registered OIDC provider")
|
||||||
|
|
||||||
# We only use openid & profile, never email
|
# We only use openid, profile & groups, never email
|
||||||
scope = "openid profile"
|
scope = "openid profile groups"
|
||||||
|
|
||||||
oidc_client = oidc_client = OIDCClient(
|
oidc_client = oidc_client = OIDCClient(
|
||||||
discovery_url=my_config.get(DISCOVERY_URL),
|
discovery_url=my_config.get(DISCOVERY_URL),
|
||||||
|
|||||||
@@ -259,7 +259,7 @@ class OpenIDAuthProvider(AuthProvider):
|
|||||||
sub = credentials.data["sub"]
|
sub = credentials.data["sub"]
|
||||||
meta = self._user_meta.get(sub, {})
|
meta = self._user_meta.get(sub, {})
|
||||||
|
|
||||||
groups = meta.get("groups", [])
|
groups = meta.get("groups") or []
|
||||||
|
|
||||||
# TODO: Allow setting which group is for admins
|
# TODO: Allow setting which group is for admins
|
||||||
group = "system-admin" if "admins" in groups else "system-users"
|
group = "system-admin" if "admins" in groups else "system-users"
|
||||||
|
|||||||
Reference in New Issue
Block a user