Skip to content

providers/oauth2: only expose URL-based avatars as picture claim - #26080

Merged
BeryJu merged 1 commit into
goauthentik:mainfrom
Tyagiquamar:fix/profile-scope-picture-url-only
Sep 13, 2026
Merged

BeryJu merged 1 commit into
goauthentik:mainfrom
Tyagiquamar:fix/profile-scope-picture-url-only

Conversation

@Tyagiquamar

Copy link
Copy Markdown
Contributor

Fixes #25978

Problem

The stock profile scope mapping (goauthentik.io/providers/oauth2/scope-profile) emits the user's avatar as the picture claim unconditionally. With the default tenant avatar settings (gravatar,initials), any user whose email has no Gravatar falls through to avatar_mode_generated, which returns the avatar inline as a base64 SVG data URI. Every ID and access token for such users carries hundreds of bytes of inline SVG, and there is currently no way to exclude the claim from tokens while keeping the default mapping.

Fix

The stock mapping now only emits picture when the avatar is an actual http(s) URL:

  • Gravatar and attribute-based URL avatars keep working unchanged.
  • Generated (initials/SVG) avatars, which are data URIs, no longer bloat tokens. This also matches the OIDC Core spec, which defines picture as "URL of the End-User's profile picture" (SHOULD be HTTPS).
  • Admins who want the inline data URIs as picture can clone the mapping and customize it; the stock mapping stays lean and spec-compliant.

Testing

  • Updated test_userinfo.py: the two userinfo tests asserted picture: self.user.avatar (a data URI in the test environment); they now assert the claim is absent, with a comment explaining why.
  • Ran in Docker (python 3.14, postgres, redis, repo-pinned deps via uv sync --frozen): authentik.providers.oauth2.tests.test_userinfo.py 2/2 pass; test_token_cc_standard.py + test_token_exchange.py (the other tests exercising profile-scope claims) 46/46 pass; ruff check and ruff format --check clean on the changed file.

The stock 'profile' scope mapping emitted the user's avatar as the
picture claim unconditionally. With the default tenant avatar settings
(gravatar,initials), any user without a Gravatar falls back to
avatar_mode_generated, which returns the avatar inline as a base64 SVG
data URI. Every issued ID and access token for such users carried
hundreds of bytes of SVG, and there was no way to exclude it.

The OIDC Core spec defines picture as the URL of the End-User's profile
picture and recommends HTTPS. Only emit the claim when the avatar is an
actual http(s) URL; generated data-URI avatars stay out of tokens.
Gravatar and custom URL avatar modes keep working, and admins who want
the data URIs can clone the mapping and customize it.

Fixes #25978
@Tyagiquamar
Tyagiquamar requested a review from a team as a code owner September 12, 2026 11:27
@netlify

netlify Bot commented Sep 12, 2026

Copy link
Copy Markdown

✅ Deploy Preview for authentik-docs ready!

Name Link
🔨 Latest commit 8ea5e88
🔍 Latest deploy log https://app.netlify.com/projects/authentik-docs/deploys/6aa5373e61df2800087ad4c7
😎 Deploy Preview https://deploy-preview-26080--authentik-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Sep 13, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.85%. Comparing base (1183742) to head (8ea5e88).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #26080      +/-   ##
==========================================
- Coverage   91.88%   91.85%   -0.03%     
==========================================
  Files        1171     1171              
  Lines       75601    75601              
  Branches     4054     4054              
==========================================
- Hits        69467    69445      -22     
- Misses       6092     6114      +22     
  Partials       42       42              
Flag Coverage Δ
conformance 33.72% <ø> (+<0.01%) ⬆️
e2e 38.40% <ø> (+<0.01%) ⬆️
integration 29.98% <ø> (-0.45%) ⬇️
rust 42.92% <ø> (ø)
unit 93.44% <ø> (ø)
unit-migrate 93.46% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@BeryJu
BeryJu merged commit 2e85913 into goauthentik:main Sep 13, 2026
138 checks passed
@BeryJu BeryJu added the backport/version-2026.8 Add this label to PRs to backport changes to version-2026.8 label Sep 13, 2026
@authentik-cherry-pick

Copy link
Copy Markdown
Contributor

🍒 Cherry-pick to version-2026.8 created: #26089

BeryJu pushed a commit that referenced this pull request Sep 14, 2026
…rry-pick #26080 to version-2026.8) (#26089)

providers/oauth2: only expose URL-based avatars as picture claim (#26080)

The stock 'profile' scope mapping emitted the user's avatar as the
picture claim unconditionally. With the default tenant avatar settings
(gravatar,initials), any user without a Gravatar falls back to
avatar_mode_generated, which returns the avatar inline as a base64 SVG
data URI. Every issued ID and access token for such users carried
hundreds of bytes of SVG, and there was no way to exclude it.

The OIDC Core spec defines picture as the URL of the End-User's profile
picture and recommends HTTPS. Only emit the claim when the avatar is an
actual http(s) URL; generated data-URI avatars stay out of tokens.
Gravatar and custom URL avatar modes keep working, and admins who want
the data URIs can clone the mapping and customize it.

Fixes #25978

Co-authored-by: Mohd Quamar Tyagi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/version-2026.8 Add this label to PRs to backport changes to version-2026.8

Projects

None yet

Development

Successfully merging this pull request may close these issues.

picture claim added to the default profile scope mapping in 2026.8 inflates access tokens, and there is no way to exclude it from the access token

2 participants