Fix null token type bug (#13236)
* Fixed null token panic from 'v1/auth/token/' endpoints and returned proper error response * Fixed panic resulting from null token_type in /auth/token/roles/{role_name} to returne proper error response * added changelog entry for PR #13236 * edit changelog entry for PR #13236
This commit is contained in:
parent
b59f8b8b4c
commit
bcd29f2b68
|
@ -0,0 +1,3 @@
|
||||||
|
```release-note:bug
|
||||||
|
core/token: Fix null token_type panic resulting from 'v1/auth/token/roles/{role_name}' endpoint
|
||||||
|
```
|
|
@ -543,6 +543,9 @@ func (c *Core) handleCancelableRequest(ctx context.Context, req *logical.Request
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
if token == nil {
|
||||||
|
return logical.ErrorResponse("bad token"), logical.ErrPermissionDenied
|
||||||
|
}
|
||||||
_, nsID := namespace.SplitIDFromString(token.(string))
|
_, nsID := namespace.SplitIDFromString(token.(string))
|
||||||
if nsID != "" {
|
if nsID != "" {
|
||||||
ns, err := NamespaceByID(ctx, nsID, c)
|
ns, err := NamespaceByID(ctx, nsID, c)
|
||||||
|
|
|
@ -3348,6 +3348,9 @@ func (ts *TokenStore) tokenStoreRoleCreateUpdate(ctx context.Context, req *logic
|
||||||
oldEntryTokenType := entry.TokenType
|
oldEntryTokenType := entry.TokenType
|
||||||
if tokenTypeRaw, ok := data.Raw["token_type"]; ok {
|
if tokenTypeRaw, ok := data.Raw["token_type"]; ok {
|
||||||
tokenTypeStr = new(string)
|
tokenTypeStr = new(string)
|
||||||
|
if tokenTypeRaw == nil {
|
||||||
|
return logical.ErrorResponse("Invalid 'token_type' value: null"), nil
|
||||||
|
}
|
||||||
*tokenTypeStr = tokenTypeRaw.(string)
|
*tokenTypeStr = tokenTypeRaw.(string)
|
||||||
delete(data.Raw, "token_type")
|
delete(data.Raw, "token_type")
|
||||||
entry.TokenType = logical.TokenTypeDefault
|
entry.TokenType = logical.TokenTypeDefault
|
||||||
|
|
Loading…
Reference in New Issue