Skip to content

Commit 42567e3

Browse files
authored
Deprecate missing_mfa, missing_sso, adding security_restrictions (#3254)
1 parent 5754b3d commit 42567e3

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/huggingface_hub/_oauth.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import urllib.parse
77
import warnings
88
from dataclasses import dataclass
9-
from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Union
9+
from typing import TYPE_CHECKING, Dict, List, Literal, Optional, Tuple, Union
1010

1111
from . import constants
1212
from .hf_api import whoami
@@ -39,10 +39,8 @@ class OAuthOrgInfo:
3939
Whether the org has a payment method set up. Hugging Face field.
4040
role_in_org (`Optional[str]`, *optional*):
4141
The user's role in the org. Hugging Face field.
42-
pending_sso (`Optional[bool]`, *optional*):
43-
Indicates if the user granted the OAuth app access to the org but didn't complete SSO. Hugging Face field.
44-
missing_mfa (`Optional[bool]`, *optional*):
45-
Indicates if the user granted the OAuth app access to the org but didn't complete MFA. Hugging Face field.
42+
security_restrictions (`Optional[List[Literal["ip", "token-policy", "mfa", "sso"]]]`, *optional*):
43+
Array of security restrictions that the user hasn't completed for this org. Possible values: "ip", "token-policy", "mfa", "sso". Hugging Face field.
4644
"""
4745

4846
sub: str
@@ -52,8 +50,7 @@ class OAuthOrgInfo:
5250
is_enterprise: bool
5351
can_pay: Optional[bool] = None
5452
role_in_org: Optional[str] = None
55-
pending_sso: Optional[bool] = None
56-
missing_mfa: Optional[bool] = None
53+
security_restrictions: Optional[List[Literal["ip", "token-policy", "mfa", "sso"]]] = None
5754

5855

5956
@dataclass
@@ -221,8 +218,7 @@ def parse_huggingface_oauth(request: "fastapi.Request") -> Optional[OAuthInfo]:
221218
is_enterprise=org.get("isEnterprise"),
222219
can_pay=org.get("canPay"),
223220
role_in_org=org.get("roleInOrg"),
224-
pending_sso=org.get("pendingSSO"),
225-
missing_mfa=org.get("missingMFA"),
221+
security_restrictions=org.get("securityRestrictions"),
226222
)
227223
for org in orgs_data
228224
]

0 commit comments

Comments
 (0)