-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix aspects of auth/token/create
request parsing
#18556
Conversation
Fixes hashicorp#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.
Hi @averche , As this PR relates to fixing field definitions that will affect OpenAPI correctness, and so the correctness of the new generated client libraries, I wonder if it is something you might be interested in looking into? |
@maxb This is a great PR and I would like to make it ready to be merged in. Would you please rebase with main such that the failing tests are fixed? |
I've updated the branch, but it looks like there are quite a few new PR checks which don't work for community PRs, due to credentials limited to branches within the main repo. |
@hghaf099 Thanks for your interest in my PR, what needs to happen next? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @maxb!
Sorry did not see the tag till today. This PR is great both for the OpenAPI correctness and for bringing the code in line with the current Vault conventions! I left a couple of nit comments. Otherwise, LGTM!
From hashicorp/vault#18556 Changes auth methods: - TokenCreate - TokenCreateAgainstRole - TokenCreateOrphan
From hashicorp/vault#18556 Changes auth methods: - TokenCreate - TokenCreateAgainstRole - TokenCreateOrphan
Fixes #18550
Currently, the
auth/token/create
family of APIs (create
,create-orphan
,create/{role}
) does non-standard parsing of requests, by directly usingmapstructure.WeakDecode(request.Data, ...)
instead of using the standardframework.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 fromcreate-orphan
.Add missing
lease
deprecated field.Rename incorrectly named
metadata
field tometa
, and change fromTypeMap
toTypeKVPairs
to reflect actual underlying Go type ismap[string]string
.Remove entirely incorrect
format
field.Add declarative
Default: true
torenewable
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
insidehandleCreateCommon
, and migrate to usingFieldData
APIs like a normal operation function.