Allow dash in account name (#806)

* Allow dash in account name
pull/809/head
Louis Ruch 6 years ago committed by GitHub
parent c33f4fe5d7
commit d8f8d60418
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -4,11 +4,17 @@ Canonical reference for changes, improvements, and bugfixes for Boundary.
## vNext
### New and Improved
* controller: Relax account login name constraints to allow dash as valid character
([Issue](https://github.com/hashicorp/boundary/issues/759))
([PR](https://github.com/hashicorp/boundary/pull/806))
### Bug Fixes
* cli: Ensure errors print to stderr when token is not found
([Issue](https://github.com/hashicorp/boundary/issues/791))
([PR](https://github.com/hashicorp/boundary/pull/799)]
([PR](https://github.com/hashicorp/boundary/pull/799))
## v0.1.2

@ -42,7 +42,7 @@ func (r *Repository) CreateAccount(ctx context.Context, scopeId string, a *Accou
return nil, fmt.Errorf("create: password account: scope id empty: %w", errors.ErrInvalidParameter)
}
if !validLoginName(a.LoginName) {
return nil, fmt.Errorf("create: password account: invalid login name; must be all-lowercase alphanumeric: %w", errors.ErrInvalidParameter)
return nil, fmt.Errorf("create: password account: invalid login name; must be all-lowercase alphanumeric, period or hyphen: %w", errors.ErrInvalidParameter)
}
cc, err := r.currentConfig(ctx, a.AuthMethodId)
@ -190,7 +190,7 @@ func (r *Repository) DeleteAccount(ctx context.Context, scopeId, withPublicId st
return rowsDeleted, nil
}
var reInvalidLoginName = regexp.MustCompile("[^a-z0-9.]")
var reInvalidLoginName = regexp.MustCompile("[^a-z0-9.-]")
func validLoginName(u string) bool {
if u == "" {
@ -236,7 +236,7 @@ func (r *Repository) UpdateAccount(ctx context.Context, scopeId string, a *Accou
case strings.EqualFold("Description", f):
case strings.EqualFold("LoginName", f):
if !validLoginName(a.LoginName) {
return nil, db.NoRowsAffected, fmt.Errorf("update: password account: invalid user name: %w", errors.ErrInvalidParameter)
return nil, db.NoRowsAffected, fmt.Errorf("update: password account: invalid user name: must be all-lowercase alphanumeric, period or hyphen %w", errors.ErrInvalidParameter)
}
changeLoginName = true
default:

@ -27,6 +27,8 @@ func TestCheckLoginName(t *testing.T) {
{"contains spaces", false},
{"NotLowerCase", false},
{"valid.loginname", true},
{"valid-loginname", true},
{"validloginname", true},
}
for _, tt := range tests {
tt := tt

Loading…
Cancel
Save