From 226a89d75e18f76763deb0ed9c637197c8c79c98 Mon Sep 17 00:00:00 2001 From: Kevin Pike Date: Fri, 8 Apr 2016 09:32:29 -0700 Subject: [PATCH] Fix username generation --- builtin/logical/rabbitmq/path_role_create.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/builtin/logical/rabbitmq/path_role_create.go b/builtin/logical/rabbitmq/path_role_create.go index 57f52181b1..a2d23b0cd5 100644 --- a/builtin/logical/rabbitmq/path_role_create.go +++ b/builtin/logical/rabbitmq/path_role_create.go @@ -4,7 +4,7 @@ import ( "fmt" "time" - "github.com/hashicorp/go-uuid" + "github.com/hashicorp/uuid" "github.com/hashicorp/vault/logical" "github.com/hashicorp/vault/logical/framework" "github.com/michaelklishin/rabbit-hole" @@ -51,18 +51,16 @@ func (b *backend) pathRoleCreateRead( lease = &configLease{Lease: 1 * time.Hour} } - userUUID, err := uuid.GenerateUUID() - if err != nil { - return nil, err + displayName := req.DisplayName + if len(displayName) > 26 { + displayName = displayName[:26] } + userUUID := uuid.GenerateUUID() username := fmt.Sprintf("%s-%s", displayName, userUUID) if len(username) > 63 { username = username[:63] } - password, err := uuid.GenerateUUID() - if err != nil { - return nil, err - } + password := uuid.GenerateUUID() // Get our connection client, err := b.Client(req.Storage)