From e0ea497cfe10dcb596ad2159e10a6c8503de69fd Mon Sep 17 00:00:00 2001 From: Jim Weber Date: Fri, 23 Sep 2016 16:57:08 -0400 Subject: [PATCH] Getting role name from the creds path used in revocation --- .gitignore | 2 ++ builtin/logical/mysql/secret_creds.go | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 011a52f52..400fe7bed 100644 --- a/.gitignore +++ b/.gitignore @@ -60,3 +60,5 @@ tags *.ipr *.iml + +testsetup.sh diff --git a/builtin/logical/mysql/secret_creds.go b/builtin/logical/mysql/secret_creds.go index 9b718945f..ce12aacd5 100644 --- a/builtin/logical/mysql/secret_creds.go +++ b/builtin/logical/mysql/secret_creds.go @@ -49,9 +49,6 @@ func (b *backend) secretCredsRenew( func (b *backend) secretCredsRevoke( req *logical.Request, d *framework.FieldData) (*logical.Response, error) { - // log.Println("b") - // log.Printf("%+v", b.Role(req.Storage, data.Get("name").(string))) - // Get the username from the internal data usernameRaw, ok := req.Secret.InternalData["username"] if !ok { @@ -66,6 +63,11 @@ func (b *backend) secretCredsRevoke( } // Get the role + pathParts := strings.Split(req.Path, "/") + if len(pathParts) < 1 { + return nil, fmt.Errorf("Role name could not be determined") + } + name := pathParts[len(pathParts)-1] role, err := b.Role(req.Storage, name) if err != nil { return nil, err