Skip to content

Fix/display name - #1305

Open
flashguerdon wants to merge 4 commits into
uc-cdis:masterfrom
AustralianBioCommons:fix/display_name
Open

flashguerdon wants to merge 4 commits into
uc-cdis:masterfrom
AustralianBioCommons:fix/display_name

Conversation

@flashguerdon

Copy link
Copy Markdown
Contributor

Link to JIRA ticket if there is one:

New Features

Breaking Changes

Bug Fixes

  • Add support for preferred_username claim in display name generation
  • Make OIDC claim field names configurable per IdP
  • Refactor to reduce repetition when fetching IdP config
  • Update post_login to check preferred_username before falling back to email/names

This allows IdPs to set user-friendly display names (e.g., "john.smith")
via the preferred_username claim, improving UX over email addresses.

Fallback hierarchy: preferred_username → email → "firstname lastname" → username

Improvements

Dependency updates

Deployment changes

- Add support for preferred_username claim in display name generation
- Make OIDC preferred_username claim field names configurable per IdP
- Refactor to reduce repetition when fetching IdP config
- Update post_login to check preferred_username before falling back to email/names

This allows IdPs to set user-friendly display names (e.g., "john.smith")
via the preferred_username claim, improving UX over email addresses.

Fallback hierarchy: preferred_username → email → "firstname lastname" → username

@Avantol13 Avantol13 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you add some unit tests for this?

or (token_result.get(email_claim_field) or "").lower() \
or " ".join(filter(None, [token_result.get(firstname_claim_field), token_result.get(lastname_claim_field)])).strip()

user.display_name = preferred_username or user.username # final fallback

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

user could be None based on the function signature so we should protect against that

# build a friendly label, prefer token preferred_username, then email, then names, then username
preferred_username = None
if token_result:
preferred_username = token_result.get("preferred_username") \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

use (

)

for multi-lines, not \

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants