mongodb secret backend: Handle cases where stored username or db is not a string as expected when revoking credentials

This commit is contained in:
Matt Hurne 2016-07-19 11:18:00 -04:00
parent 75a5fbd8fe
commit f8e6bcbb69

View file

@ -51,6 +51,9 @@ func (b *backend) secretCredsRevoke(req *logical.Request, d *framework.FieldData
return nil, fmt.Errorf("secret is missing username internal data")
}
username, ok := usernameRaw.(string)
if !ok {
return nil, fmt.Errorf("username internal data is not a string")
}
// Get the db from the internal data
dbRaw, ok := req.Secret.InternalData["db"]
@ -58,6 +61,9 @@ func (b *backend) secretCredsRevoke(req *logical.Request, d *framework.FieldData
return nil, fmt.Errorf("secret is missing db internal data")
}
db, ok := dbRaw.(string)
if !ok {
return nil, fmt.Errorf("db internal data is not a string")
}
// Get our connection
session, err := b.Session(req.Storage)