Skip to content

Commit

Permalink
Fix aspects of auth/token/create request parsing (#18556)
Browse files Browse the repository at this point in the history
* Fix aspects of `auth/token/create` request parsing

Fixes #18550

Currently, the `auth/token/create` family of APIs (`create`,
`create-orphan`, `create/{role}`) does non-standard parsing of requests,
by directly using `mapstructure.WeakDecode(request.Data, ...)` instead
of using the standard `framework.FieldData` abstraction.

Furthermore, the fields declared for these APIs are incorrect, leading
to inappropriate OpenAPI generation, and inappropriate warnings about
ignored parameters.

Detailed changes:

* Factor out triplicated definitions of common fields across these three
  APIs.

* Remove incorrect `role_name` field from `create-orphan`.

* Add missing `lease` deprecated field.

* Rename incorrectly named `metadata` field to `meta`, and change from
  `TypeMap` to `TypeKVPairs` to reflect actual underlying Go type is
  `map[string]string`.

* Remove entirely incorrect `format` field.

* Add declarative `Default: true` to `renewable` field, to match
  behaviour currently implemented in code.

* Having fixed the field definitions to match current usage, remove the
  secondary decoding of the request via `mapstructure` inside
  `handleCreateCommon`, and migrate to using `FieldData` APIs like
  a normal operation function.

* Add changelog

* Rephrase comment.
  • Loading branch information
maxb authored Jul 10, 2023
1 parent e29842e commit 3bf1299
Show file tree
Hide file tree
Showing 2 changed files with 135 additions and 255 deletions.
3 changes: 3 additions & 0 deletions changelog/18556.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
auth/token: Fix parsing of `auth/token/create` fields to avoid incorrect warnings about ignored parameters
```
Loading

0 comments on commit 3bf1299

Please sign in to comment.