juanfont / headscale

An open source, self-hosted implementation of the Tailscale control server
BSD 3-Clause "New" or "Revised" License
22.63k stars 1.25k forks source link

[Feature] OIDC with permanent ID #1990

Closed adipierro closed 4 days ago

adipierro commented 3 months ago

Use case

Currently, if user account in external system might have an email or username changed, OIDC authentication in Headscale won't match an existing user in DB, and another user will be created instead.

Description

Use OIDC sub claim as a permanent identifier for a user

If we use sub claim as a permanent unique ID for a user, we can match OIDC authenticated user with it instead of a username, and update a username (email) in DB if it differs. We should make updating optional as ACLs might stop applying to affected users.

Use and save OIDC email claim regardless of email domain stripping

A discussion is probably needed.

Screenshot 2024-06-22 at 5 21 29 PM

email, if available, could be used to display as LoginName in Tailscale clients. Or, it could be another way to identify users in ACLs if strip_email_domain is turned on, particularly, to avoid username collisions if multiple domains are allowed to login.

But considering https://github.com/juanfont/headscale/pull/1987, we might not need to strip email domains anymore.

Contribution

IamTaoChen commented 3 months ago

Maybe not sub, we can design the username claim, e.g. preferred_username

SirBomble commented 3 months ago

I believe this PR is attempting to add support for preferred_username https://github.com/juanfont/headscale/pull/1997

adipierro commented 3 months ago

I think sub should be used as an internal identifier for matching the user, useful in cases username has changed upstream at OIDC. Of course, it should not be used as end-user display name or in CLI.

micolous commented 2 days ago

I do not think this is actually fixed by #2020, because the always-active fallback behaviour will still allow account take-overs, even if the target account has been "updated" to use the sub parameter.