Implement initial flow (#2)
This commit is contained in:
committed by
GitHub
parent
1c8c7ed14a
commit
8ba494c49c
@@ -4,6 +4,13 @@ from typing import OrderedDict
|
||||
import voluptuous as vol
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .endpoints.welcome import OIDCWelcomeView
|
||||
from .endpoints.redirect import OIDCRedirectView
|
||||
from .endpoints.finish import OIDCFinishView
|
||||
from .endpoints.callback import OIDCCallbackView
|
||||
|
||||
from .oidc_client import OIDCClient
|
||||
|
||||
DOMAIN = "auth_oidc"
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -13,7 +20,9 @@ CONFIG_SCHEMA = vol.Schema(
|
||||
{
|
||||
DOMAIN: vol.Schema(
|
||||
{
|
||||
|
||||
vol.Required("client_id"): vol.Coerce(str),
|
||||
vol.Optional("client_secret"): vol.Coerce(str),
|
||||
vol.Required("discovery_url"): vol.Url(),
|
||||
}
|
||||
)
|
||||
},
|
||||
@@ -34,5 +43,18 @@ async def async_setup(hass: HomeAssistant, config):
|
||||
providers.update(hass.auth._providers)
|
||||
hass.auth._providers = providers
|
||||
|
||||
_LOGGER.debug("Added OIDC provider")
|
||||
_LOGGER.debug("Added OIDC provider for Home Assistant")
|
||||
|
||||
# Define some fields
|
||||
discovery_url = config[DOMAIN]["discovery_url"]
|
||||
client_id = config[DOMAIN]["client_id"]
|
||||
scope = "openid profile email"
|
||||
|
||||
oidc_client = oidc_client = OIDCClient(discovery_url, client_id, scope)
|
||||
|
||||
hass.http.register_view(OIDCWelcomeView())
|
||||
hass.http.register_view(OIDCRedirectView(oidc_client))
|
||||
hass.http.register_view(OIDCCallbackView(oidc_client, provider))
|
||||
hass.http.register_view(OIDCFinishView())
|
||||
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user