Skip to content

Commit

Permalink
🐛 Implement oidcdb_userinfo_claims_source on base model
Browse files Browse the repository at this point in the history
Instead of the concrete model - the model field exists on the base
model, so subclasses can lift on this configuration.
  • Loading branch information
sergei-maertens committed May 21, 2024
1 parent b51573e commit e48d55a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
8 changes: 4 additions & 4 deletions mozilla_django_oidc_db/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,10 @@ def oidcdb_username_claim(self) -> ClaimPath:
"""
return get_default_username_claim()

@property
def oidcdb_userinfo_claims_source(self) -> UserInformationClaimsSources:
return self.userinfo_claims_source


class OpenIDConnectConfig(CachingMixin, OpenIDConnectConfigBase):
"""
Expand Down Expand Up @@ -388,10 +392,6 @@ def oidcdb_username_claim(self) -> ClaimPath:
username_claim: ClaimPath = self.username_claim # type: ignore
return username_claim

@property
def oidcdb_userinfo_claims_source(self) -> UserInformationClaimsSources:
return self.userinfo_claims_source

@property
def oidcdb_claim_mapping(self) -> dict[str, ClaimPath]:
return self.claim_mapping
Expand Down
1 change: 0 additions & 1 deletion tests/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def test_authentication_loads_config_from_init_state(
@pytest.mark.parametrize(
"setting,expected",
(
("OIDCDB_USERINFO_CLAIMS_SOURCE", UserInformationClaimsSources.id_token),
("OIDCDB_USERNAME_CASE_SENSITIVE", False),
("OIDCDB_CLAIM_MAPPING", {"foo": "bar"}),
("OIDCDB_GROUPS_CLAIM", ["roles"]),
Expand Down

0 comments on commit e48d55a

Please sign in to comment.