sources/oauth: handle error in auzre_ad when ID Can't be extracted
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
dc75d7b7f0
commit
a8998a6356
|
@ -1,5 +1,5 @@
|
||||||
"""AzureAD OAuth2 Views"""
|
"""AzureAD OAuth2 Views"""
|
||||||
from typing import Any
|
from typing import Any, Optional
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
from authentik.sources.oauth.models import OAuthSource, UserOAuthSourceConnection
|
from authentik.sources.oauth.models import OAuthSource, UserOAuthSourceConnection
|
||||||
|
@ -10,8 +10,11 @@ from authentik.sources.oauth.views.callback import OAuthCallback
|
||||||
class AzureADOAuthCallback(OAuthCallback):
|
class AzureADOAuthCallback(OAuthCallback):
|
||||||
"""AzureAD OAuth2 Callback"""
|
"""AzureAD OAuth2 Callback"""
|
||||||
|
|
||||||
def get_user_id(self, source: OAuthSource, info: dict[str, Any]) -> str:
|
def get_user_id(self, source: OAuthSource, info: dict[str, Any]) -> Optional[str]:
|
||||||
return str(UUID(info.get("objectId")).int)
|
try:
|
||||||
|
return str(UUID(info.get("objectId")).int)
|
||||||
|
except TypeError:
|
||||||
|
return None
|
||||||
|
|
||||||
def get_user_enroll_context(
|
def get_user_enroll_context(
|
||||||
self,
|
self,
|
||||||
|
|
Reference in a new issue