Skip to content

Commit

Permalink
check username and fullname against header
Browse files Browse the repository at this point in the history
closes #23
  • Loading branch information
Langhammer, Jens committed Feb 7, 2021
1 parent 65ace8c commit 53495f6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,4 @@ dmypy.json
.pyre/

# End of https://www.gitignore.io/api/python
hass-config/
config/
5 changes: 4 additions & 1 deletion custom_components/auth_header/headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from aiohttp.web_request import Request
from homeassistant.auth.models import Credentials, User, UserMeta
from homeassistant.auth.providers import (
AUTH_PROVIDER_SCHEMA,
AUTH_PROVIDERS,
AuthProvider,
LoginFlow,
Expand Down Expand Up @@ -146,6 +145,10 @@ async def async_step_init(
return self.async_abort(reason="not_allowed")

for user in self._available_users:
for cred in user.credentials:
if "username" in cred.data:
if cred.data["username"] == self._remote_user:
return await self.async_finish({"user": user.id})
if user.name == self._remote_user:
return await self.async_finish({"user": user.id})

Expand Down

0 comments on commit 53495f6

Please sign in to comment.