Fix username generation

This commit is contained in:
Kevin Pike 2016-04-08 09:32:29 -07:00
parent fc61a7695b
commit 706ed5839e
1 changed files with 6 additions and 8 deletions

View File

@ -4,7 +4,7 @@ import (
"fmt" "fmt"
"time" "time"
"github.com/hashicorp/go-uuid" "github.com/hashicorp/uuid"
"github.com/hashicorp/vault/logical" "github.com/hashicorp/vault/logical"
"github.com/hashicorp/vault/logical/framework" "github.com/hashicorp/vault/logical/framework"
"github.com/michaelklishin/rabbit-hole" "github.com/michaelklishin/rabbit-hole"
@ -51,18 +51,16 @@ func (b *backend) pathRoleCreateRead(
lease = &configLease{Lease: 1 * time.Hour} lease = &configLease{Lease: 1 * time.Hour}
} }
userUUID, err := uuid.GenerateUUID() displayName := req.DisplayName
if err != nil { if len(displayName) > 26 {
return nil, err displayName = displayName[:26]
} }
userUUID := uuid.GenerateUUID()
username := fmt.Sprintf("%s-%s", displayName, userUUID) username := fmt.Sprintf("%s-%s", displayName, userUUID)
if len(username) > 63 { if len(username) > 63 {
username = username[:63] username = username[:63]
} }
password, err := uuid.GenerateUUID() password := uuid.GenerateUUID()
if err != nil {
return nil, err
}
// Get our connection // Get our connection
client, err := b.Client(req.Storage) client, err := b.Client(req.Storage)