[Question] Is this supposed to be like this? #978

Closed
opened 2025-12-29 02:26:59 +01:00 by adam · 2 comments
Owner

Originally created by @bitbronze on GitHub (Mar 18, 2025).

Use case

This is affecting some behavior in ListPreauthKeys.

Description

In file users.go

// Username is the main way to get the username of a user,
// it will return the email if it exists, the name if it exists,
// the OIDCIdentifier if it exists, and the ID if nothing else exists.
// Email and OIDCIdentifier will be set when the user has headscale
// enabled with OIDC, which means that there is a domain involved which
// should be used throughout headscale, in information returned to the
// user and the Policy engine.
func (u *User) Username() string {
	return cmp.Or(
		u.Email,
		u.Name,
		u.ProviderIdentifier.String,
		u.StringID(),
	)
}

The email is returned with priority over the actual username. Should we swap u.Email and u.Name?

Contribution

  • I can write the design doc for this feature
  • I can contribute this feature

How can it be implemented?

No response

Originally created by @bitbronze on GitHub (Mar 18, 2025). ### Use case This is affecting some behavior in ListPreauthKeys. ### Description In file [users.go](https://github.com/juanfont/headscale/blob/00d5d647ed560b716c5277cb81228a9442b25cf3/hscontrol/types/users.go#L86) ``` // Username is the main way to get the username of a user, // it will return the email if it exists, the name if it exists, // the OIDCIdentifier if it exists, and the ID if nothing else exists. // Email and OIDCIdentifier will be set when the user has headscale // enabled with OIDC, which means that there is a domain involved which // should be used throughout headscale, in information returned to the // user and the Policy engine. func (u *User) Username() string { return cmp.Or( u.Email, u.Name, u.ProviderIdentifier.String, u.StringID(), ) } ``` The email is returned with priority over the actual username. Should we swap u.Email and u.Name? ### Contribution - [ ] I can write the design doc for this feature - [ ] I can contribute this feature ### How can it be implemented? _No response_
adam added the enhancement label 2025-12-29 02:26:59 +01:00
adam closed this issue 2025-12-29 02:26:59 +01:00
Author
Owner

@kradalby commented on GitHub (Mar 19, 2025):

This is intended behaviour.

Is the affected behaviour that the cli don't use id?

@kradalby commented on GitHub (Mar 19, 2025): This is intended behaviour. Is the affected behaviour that the cli don't use id?
Author
Owner

@bitbronze commented on GitHub (Mar 19, 2025):

API returns emails instead of username in the "user" field. And for other API commands Headscale expects username not email. So for example expiring a preauthkey.

@bitbronze commented on GitHub (Mar 19, 2025): API returns emails instead of username in the "user" field. And for other API commands Headscale expects username not email. So for example expiring a preauthkey.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#978