-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathauthentication_policy.py
More file actions
32 lines (27 loc) · 1.08 KB
/
authentication_policy.py
File metadata and controls
32 lines (27 loc) · 1.08 KB
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
from enum import IntEnum
class AuthenticationPolicy(IntEnum):
USER_DEVICE_SETTING = 0x01
USER_DEVICE_SETTING_SECURE_ACTION = 0x02
FORCE_USER_AUTHENTICATION = 0x03
@classmethod
def parse(cls, value):
if value is None:
return cls.USER_DEVICE_SETTING
if isinstance(value, cls):
return value
if isinstance(value, int):
return cls(value)
normalized = str(value).strip().lower().replace(" ", "_")
aliases = {
"express": cls.USER_DEVICE_SETTING,
"original": cls.USER_DEVICE_SETTING,
"user": cls.USER_DEVICE_SETTING,
"user_device_setting": cls.USER_DEVICE_SETTING,
"secure": cls.USER_DEVICE_SETTING_SECURE_ACTION,
"user_device_setting_secure_action": cls.USER_DEVICE_SETTING_SECURE_ACTION,
"force": cls.FORCE_USER_AUTHENTICATION,
"force_user_authentication": cls.FORCE_USER_AUTHENTICATION,
}
if normalized in aliases:
return aliases[normalized]
return cls[normalized.upper()]