1
0
mirror of https://github.com/juanfont/headscale.git synced 2025-06-19 01:18:37 +02:00

validate email prefix as username

This commit is contained in:
Ventsislav Georgiev 2025-05-18 18:29:46 +03:00
parent 101b998b21
commit 3a66286c48
No known key found for this signature in database

View File

@ -322,9 +322,11 @@ func (u *User) FromClaim(claims *OIDCClaims) {
if claims.Email != "" && claims.EmailVerified {
emailParts := strings.Split(claims.Email, "@")
if len(emailParts) > 0 && emailParts[0] != "" {
err = util.ValidateUsername(emailParts[0])
if err == nil {
u.Name = emailParts[0]
log.Debug().Msgf("Using email prefix %s as name", u.Name)
} else {
log.Debug().Err(err).Msgf("Email prefix %s is not valid username", emailParts[0])
}
}
}