Move checking non-assignable policies above the actual token creation
This commit is contained in:
parent
be39df9887
commit
d7f6218869
|
@ -1307,11 +1307,6 @@ func (ts *TokenStore) handleCreateCommon(
|
|||
renewable = false
|
||||
}
|
||||
|
||||
// Create the token
|
||||
if err := ts.create(&te); err != nil {
|
||||
return logical.ErrorResponse(err.Error()), logical.ErrInvalidRequest
|
||||
}
|
||||
|
||||
// Prevent internal policies from being assigned to tokens
|
||||
for _, policy := range te.Policies {
|
||||
if strutil.StrListContains(nonAssignablePolicies, policy) {
|
||||
|
@ -1319,6 +1314,11 @@ func (ts *TokenStore) handleCreateCommon(
|
|||
}
|
||||
}
|
||||
|
||||
// Create the token
|
||||
if err := ts.create(&te); err != nil {
|
||||
return logical.ErrorResponse(err.Error()), logical.ErrInvalidRequest
|
||||
}
|
||||
|
||||
// Generate the response
|
||||
resp.Auth = &logical.Auth{
|
||||
DisplayName: te.DisplayName,
|
||||
|
|
Loading…
Reference in New Issue