Skip to content
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

acl: demonstrate ResolveTokenForRequest #12168

Closed
wants to merge 2 commits into from

Conversation

dnephin
Copy link
Contributor

@dnephin dnephin commented Jan 23, 2022

Branched from #12167, this PR demonstrates the proposed (in #11690) replacement for ResolveTokenAndDefaultMeta.

This new method ResolveTokenForRequest accepts a single arg and handles setting the default enterprise meta from the token.

It does not set those values in the AuthorizerContext. Very few calls to ResolveTokenAndDefaultMeta actually make use of this AuthorizerContext arg. As part of the migration we can populate the AuthorizerContext from the caller, but in the future we should be able to remove the need for AuthorizerContext by instead accepting an interface to the methods on Authorizer. An example of that can be seen in #12169.

TODO:

  • replace all calls to ResolveTokenAndDefaultMeta with ResolveTokenForRequest

@dnephin dnephin added the pr/no-changelog PR does not need a corresponding .changelog entry label Jan 23, 2022
Comment on lines +1176 to +1183
type ACLRequest interface {
TokenSecret() string

// Merge sets the fields in this request to the values from source, if the
// request does not already have a value.
// TODO: rename
Merge(source *structs.EnterpriseMeta)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost every one of our existing request structs already implements this interface (as described in #11690). Some may not have a Merge method if they don't have EnterpriseMeta, but we can easily implement a no-op version to embed in those structs.

Comment on lines +1179 to +1180
// Merge sets the fields in this request to the values from source, if the
// request does not already have a value.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Merge sets the fields in this request to the values from source, if the
// request does not already have a value.
// Merge sets the fields in this request to the values from source, if the
// request does not already have a value for those fields.

This change allows us to remove one of the last remaining duplicate
resolve token methods (Server.ResolveToken).

With this change we are down to only 2, where the second one also
handles setting the default EnterpriseMeta from the token.
@vercel vercel bot temporarily deployed to Preview – consul January 26, 2022 22:45 Inactive
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging January 26, 2022 22:45 Inactive
@dnephin dnephin force-pushed the dnephin/acl-resolve-token-3 branch 2 times, most recently from e4d0b9f to 343b6de Compare January 31, 2022 23:04
Base automatically changed from dnephin/acl-resolve-token-3 to main February 1, 2022 00:21
@hashicorp-cla
Copy link

hashicorp-cla commented Mar 12, 2022

CLA assistant check
All committers have signed the CLA.

@github-actions
Copy link

This pull request has been automatically flagged for inactivity because it has not been acted upon in the last 60 days. It will be closed if no new activity occurs in the next 30 days. Please feel free to re-open to resurrect the change if you feel this has happened by mistake. Thank you for your contributions.

@github-actions github-actions bot added the meta/stale Automatically flagged for inactivity by stalebot label Jun 17, 2022
@github-actions
Copy link

Closing due to inactivity. If you feel this was a mistake or you wish to re-open at any time in the future, please leave a comment and it will be re-surfaced for the maintainers to review.

@github-actions github-actions bot closed this Aug 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
meta/stale Automatically flagged for inactivity by stalebot pr/no-changelog PR does not need a corresponding .changelog entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants