[PR #2611] [CLOSED] feat(oidc): allow email prefix as username fallback #2762

Closed
opened 2025-12-29 04:18:52 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/juanfont/headscale/pull/2611
Author: @ventsislav-georgiev
Created: 5/18/2025
Status: Closed

Base: mainHead: oidc-name-email-fallback


📝 Commits (2)

  • 101b998 feat(oidc): allow email prefix as username fallback
  • 3a66286 validate email prefix as username

📊 Changes

3 files changed (+35 additions, -1 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 hscontrol/types/users.go (+11 -1)
📝 hscontrol/types/users_test.go (+22 -0)

📄 Description

When using OIDC login and the username is not properly passed with the claims the login fails with:

ERR http internal server error error="creating or updating user: constraint failed: UNIQUE constraint failed: users.name (2067)" code=500

The proposed solution is to use the email prefix (before @) as the username when the email is marked as verified. [Question] Should we use the whole email as fallback?

This resolves the OIDC login from trusted domains like using Google's OAuth 2.0.
Issue ref: https://github.com/juanfont/headscale/issues/2475


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/juanfont/headscale/pull/2611 **Author:** [@ventsislav-georgiev](https://github.com/ventsislav-georgiev) **Created:** 5/18/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `oidc-name-email-fallback` --- ### 📝 Commits (2) - [`101b998`](https://github.com/juanfont/headscale/commit/101b998b2154ec7c02f9692bcbdd00d11e155a9c) feat(oidc): allow email prefix as username fallback - [`3a66286`](https://github.com/juanfont/headscale/commit/3a66286c48206314d2a1ee9faf3b5b08285adb8f) validate email prefix as username ### 📊 Changes **3 files changed** (+35 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `hscontrol/types/users.go` (+11 -1) 📝 `hscontrol/types/users_test.go` (+22 -0) </details> ### 📄 Description When using OIDC login and the username is not properly passed with the claims the login fails with: ``` ERR http internal server error error="creating or updating user: constraint failed: UNIQUE constraint failed: users.name (2067)" code=500 ``` The proposed solution is to use the email prefix (before @) as the username when the email is marked as verified. _[Question] Should we use the whole email as fallback?_ This resolves the OIDC login from trusted domains like using Google's OAuth 2.0. Issue ref: https://github.com/juanfont/headscale/issues/2475 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 04:18:52 +01:00
adam closed this issue 2025-12-29 04:18:52 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#2762