blob: 110de3ef4fb88b1d03201295a4c771a8fc6cb213 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
from typing import Any
from .auth import BaseAuth, SSOAuth
class Saml2(SSOAuth):
LOGIN_URL = 'auth/saml2/login'
LOGOUT_URL = 'auth/saml2/slo'
sso = True
class Saml2Config(BaseAuth.Config):
onelogin_settings: Any
def __init__(self, onelogin_settings):
self.onelogin_settings = onelogin_settings
def get_username_attribute(self):
return self.onelogin_settings['sp']['attributeConsumingService']['requestedAttributes'][0][
'name']
def to_dict(self) -> 'Saml2Config':
return {
'onelogin_settings': self.onelogin_settings
}
@classmethod
def from_dict(cls, s_dict: Saml2Config) -> 'Saml2':
try:
return Saml2(s_dict['onelogin_settings'])
except KeyError:
return Saml2({})
@classmethod
def get_auth_name(cls):
return cls.__name__.lower()
|