Skip to content

Add custom_attributes field to SSO Profile #434

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

Merged
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
2 changes: 1 addition & 1 deletion tests/test_sso.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def mock_magic_link_profile(self):
idp_id="",
first_name=None,
last_name=None,
profile=None,
role=None,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was incorrect in fixture, just fixing.

groups=None,
raw_attributes={},
).dict()
Expand Down
6 changes: 5 additions & 1 deletion tests/utils/fixtures/mock_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class MockProfile(Profile):
def __init__(self, id: str):
super().__init__(
object="profile",
id="prof_01DWAS7ZQWM70PV93BFV1V78QV",
id=id or "prof_01DWAS7ZQWM70PV93BFV1V78QV",
email="[email protected]",
first_name="WorkOS",
last_name="Demo",
Expand All @@ -16,10 +16,14 @@ def __init__(self, id: str):
connection_id="conn_01EMH8WAK20T42N2NBMNBCYHAG",
connection_type="OktaSAML",
idp_id="00u1klkowm8EGah2H357",
custom_attributes={
"license": "professional",
},
raw_attributes={
"email": "[email protected]",
"first_name": "WorkOS",
"last_name": "Demo",
"groups": ["Admins", "Developers"],
"license": "professional",
},
)
3 changes: 2 additions & 1 deletion workos/types/sso/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ class Profile(WorkOSModel):
idp_id: str
role: Optional[ProfileRole] = None
groups: Optional[Sequence[str]] = None
raw_attributes: Mapping[str, Any]
custom_attributes: Optional[Mapping[str, Any]] = None
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to add a generic type for custom_attributes that developers can override, but ran into some mypy limitations with default values for generic types. Keeping this as-is for now.

raw_attributes: Optional[Mapping[str, Any]] = None


class ProfileAndToken(WorkOSModel):
Expand Down