mirror of
https://github.com/juanfont/headscale.git
synced 2025-02-08 10:18:01 +09:00
no edit of oidc users, minimum hostname length (#2393)
* return an error when renaming users from OIDC * set minimum hostname length of 2
This commit is contained in:
parent
9bd143852f
commit
1c7f3bc440
3 changed files with 15 additions and 0 deletions
|
@ -20,6 +20,10 @@
|
||||||
[#2350](https://github.com/juanfont/headscale/pull/2350)
|
[#2350](https://github.com/juanfont/headscale/pull/2350)
|
||||||
- Print Tailscale version instead of capability versions for outdated nodes
|
- Print Tailscale version instead of capability versions for outdated nodes
|
||||||
[#2391](https://github.com/juanfont/headscale/pull/2391)
|
[#2391](https://github.com/juanfont/headscale/pull/2391)
|
||||||
|
- Do not allow renaming of users from OIDC
|
||||||
|
[#2393](https://github.com/juanfont/headscale/pull/2393)
|
||||||
|
- Change minimum hostname length to 2
|
||||||
|
[#2393](https://github.com/juanfont/headscale/pull/2393)
|
||||||
- Pre auth keys belonging to a user are no longer deleted with the user
|
- Pre auth keys belonging to a user are no longer deleted with the user
|
||||||
[#2396](https://github.com/juanfont/headscale/pull/2396)
|
[#2396](https://github.com/juanfont/headscale/pull/2396)
|
||||||
- Pre auth keys that are used by a node can no longer be deleted
|
- Pre auth keys that are used by a node can no longer be deleted
|
||||||
|
|
|
@ -81,6 +81,8 @@ func (hsdb *HSDatabase) RenameUser(uid types.UserID, newName string) error {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var ErrCannotChangeOIDCUser = errors.New("cannot edit OIDC user")
|
||||||
|
|
||||||
// RenameUser renames a User. Returns error if the User does
|
// RenameUser renames a User. Returns error if the User does
|
||||||
// not exist or if another User exists with the new name.
|
// not exist or if another User exists with the new name.
|
||||||
func RenameUser(tx *gorm.DB, uid types.UserID, newName string) error {
|
func RenameUser(tx *gorm.DB, uid types.UserID, newName string) error {
|
||||||
|
@ -94,6 +96,10 @@ func RenameUser(tx *gorm.DB, uid types.UserID, newName string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if oldUser.Provider == util.RegisterMethodOIDC {
|
||||||
|
return ErrCannotChangeOIDCUser
|
||||||
|
}
|
||||||
|
|
||||||
oldUser.Name = newName
|
oldUser.Name = newName
|
||||||
|
|
||||||
if err := tx.Save(&oldUser).Error; err != nil {
|
if err := tx.Save(&oldUser).Error; err != nil {
|
||||||
|
|
|
@ -65,6 +65,11 @@ func ValidateUsername(username string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func CheckForFQDNRules(name string) error {
|
func CheckForFQDNRules(name string) error {
|
||||||
|
// Ensure the username meets the minimum length requirement
|
||||||
|
if len(name) < 2 {
|
||||||
|
return errors.New("name must be at least 2 characters long")
|
||||||
|
}
|
||||||
|
|
||||||
if len(name) > LabelHostnameLength {
|
if len(name) > LabelHostnameLength {
|
||||||
return fmt.Errorf(
|
return fmt.Errorf(
|
||||||
"DNS segment must not be over 63 chars. %v doesn't comply with this rule: %w",
|
"DNS segment must not be over 63 chars. %v doesn't comply with this rule: %w",
|
||||||
|
|
Loading…
Reference in a new issue