Skip to content

Commit

Permalink
📝 [#94] Update documentation and mention dots in claims are supported
Browse files Browse the repository at this point in the history
  • Loading branch information
sergei-maertens committed May 2, 2024
1 parent 308e228 commit d25ea89
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
18 changes: 13 additions & 5 deletions docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ The name of the claim that is used for the ``User.username`` property
can be configured via the admin (**Username claim**). By default, the username is derived from the ``sub`` claim that
is returned by the OIDC provider.

If the desired claim is nested in one or more objects, its path can be specified with dots, e.g.:
If the desired claim is nested in one or more objects, you can specify the segments
of the path:

.. code-block:: json
Expand All @@ -175,17 +176,24 @@ If the desired claim is nested in one or more objects, its path can be specified
}
}
Can be retrieved by setting the username claim to ``some.nested.claim``
Can be retrieved by setting the username claim (array field) to:

.. note::
The username claim does not support claims that have dots in their name, it cannot be configured to retrieve the following claim for instance:
- some
- nested
- claim

If the claim has dots in it, you can specify those in a segment:

.. code-block:: json
{
"some.dotted.claim": "foo"
}
can be retrieved with:

- some.dotted.claim

User profile
------------

Expand Down Expand Up @@ -254,4 +262,4 @@ and ``OIDCAuthenticationBackend.config_class`` to be this new class.

.. _mozilla-django-oidc settings documentation: https://mozilla-django-oidc.readthedocs.io/en/stable/settings.html

.. _OIDC spec: https://openid.net/specs/openid-connect-discovery-1_0.html#WellKnownRegistry
.. _OIDC spec: https://openid.net/specs/openid-connect-discovery-1_0.html#WellKnownRegistry
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@

import mozilla_django_oidc_db.fields
import mozilla_django_oidc_db.models
import mozilla_django_oidc_db.settings as oidc_settings


def flush_cache():
if not (cache_name := getattr(settings, "SOLO_CACHE", "")):
cache_name = getattr(
settings,
"MOZILLA_DJANGO_OIDC_DB_CACHE",
oidc_settings.MOZILLA_DJANGO_OIDC_DB_CACHE,
)
if not cache_name:
return
caches[cache_name].clear()

Expand Down
1 change: 0 additions & 1 deletion mozilla_django_oidc_db/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ def obfuscate_claims(claims: dict, claims_to_obfuscate: list[list[str]]) -> dict
copied_claims = deepcopy(claims)
for claim_bits in claims_to_obfuscate:
claim_path = Path(*claim_bits)
# NOTE: this does not support claim names that have dots in them
claim_value = glom(copied_claims, claim_path)
assign(copied_claims, claim_path, obfuscate_claim_value(claim_value))
return copied_claims
Expand Down

0 comments on commit d25ea89

Please sign in to comment.