Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make tid and oid optional to allow User validation in B2C #145

Merged
merged 2 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions fastapi_azure_auth/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ class Claims(BaseModel):
...,
description='The principal associated with the token.',
)
oid: str = Field(
...,
oid: Optional[str] = Field(
default=None,
description='The immutable identifier for the requestor, which is the verified identity of the user or service principal',
)
tid: str = Field(
...,
tid: Optional[str] = Field(
default=None,
description='Represents the tenant that the user is signing in to',
)
uti: Optional[str] = Field(
Expand Down
6 changes: 3 additions & 3 deletions tests/test_openapi_scheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,12 @@
'description': 'The principal associated with the token.',
},
'oid': {
'type': 'string',
'anyOf': [{'type': 'string'}, {'type': 'null'}],
'title': 'Oid',
'description': 'The immutable identifier for the requestor, which is the verified identity of the user or service principal',
},
'tid': {
'type': 'string',
'anyOf': [{'type': 'string'}, {'type': 'null'}],
'title': 'Tid',
'description': 'Represents the tenant that the user is signing in to',
},
Expand Down Expand Up @@ -383,7 +383,7 @@
},
},
'type': 'object',
'required': ['aud', 'iss', 'iat', 'nbf', 'exp', 'sub', 'oid', 'tid', 'ver', 'claims', 'access_token'],
'required': ['aud', 'iss', 'iat', 'nbf', 'exp', 'sub', 'ver', 'claims', 'access_token'],
'title': 'User',
},
},
Expand Down
2 changes: 0 additions & 2 deletions tests/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,13 @@ def get_utc_now_as_unix_timestamp() -> int:
def test_user_missing_optionals():
user = User(
aud='Dummy',
tid='Dummy',
access_token='Dummy',
claims={'oid': 'Dummy oid'},
iss='https://dummy-platform.dummylogin.com/dummy-uid/v2.0/',
iat=get_utc_now_as_unix_timestamp(),
nbf=get_utc_now_as_unix_timestamp(),
exp=get_utc_now_as_unix_timestamp(),
sub='dummy-sub',
oid='dummy-oid',
ver='1.0',
scp='AccessAsUser',
)
Expand Down
Loading