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

feat(cli): Extend CLI with v1 authorization commands #19829

Merged
merged 3 commits into from
Oct 29, 2020

Conversation

stuartcarnie
Copy link
Contributor

@stuartcarnie stuartcarnie commented Oct 27, 2020

Closes #19765

This commit add a series of new subcommands to the influx CLI tool. The specific commands are:

  • influx v1 to host any InfluxDB v1 specific commands
  • influx v1 auth for v1 authorization token management.
  • influx v1 auth set-password to assign a password to a token for V1 API authorization

The v1 auth commands enable access to the private authorization APIs (see #19815 and #19837) used to manage authorization tokens for v1 compatibility APIs, including:

  • /write
  • /query

The final issue, #19768 will update the authorization handlers to use these new tokens and their assigned passwords.

@stuartcarnie stuartcarnie added area/tooling area/2.x OSS 2.0 related issues and PRs labels Oct 27, 2020
@stuartcarnie stuartcarnie self-assigned this Oct 27, 2020
@stuartcarnie stuartcarnie requested review from a team and gavincabbage and removed request for a team October 27, 2020 00:33
@stuartcarnie
Copy link
Contributor Author

@gavincabbage the team-assigner gods picked you!

Base automatically changed from sgc/issues/19812 to master October 27, 2020 15:26
@stuartcarnie stuartcarnie marked this pull request as draft October 27, 2020 15:48
@stuartcarnie
Copy link
Contributor Author

@gavincabbage I'll request a review when this is ready, as we need to make a few additional changes

This commit add a series of new subcommands to the `influx` CLI tool.

* `influx v1` to host any InfluxDB v1 specific commands
* `influx v1 auth` for v1 authorization token management.

The commands provide access to the private authorization APIs
used to manage authorization tokens for v1 compatibility APIs,
including:

* `/write`
* `/query`

Closes #19765
Remove remnants of previous token implementation

* As of #19840, V1 API tokens will be authorized using bcrypt passwords
* Added capability to HTTP API to search for tokens by ID or Token
@stuartcarnie stuartcarnie marked this pull request as ready for review October 28, 2020 22:22
@stuartcarnie
Copy link
Contributor Author

@gavincabbage this PR is ready for review

Copy link
Contributor

@gavincabbage gavincabbage left a comment

Choose a reason for hiding this comment

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

Looks good Stuart- just wanted to ask, would it be appropriate to add some tests for all the business logic in v1_authorization.go?

@stuartcarnie
Copy link
Contributor Author

would it be appropriate to add some tests for all the business logic in v1_authorization.go?

I'm not really sure we have established a way to test CLI commands and I don't see precedent for testing any of the other ones. We do test the HTTP APIs that the CLI commands call, however.

@stuartcarnie
Copy link
Contributor Author

Well, it looks like bucket has some tests:

t.Run("create", func(t *testing.T) {

@stuartcarnie
Copy link
Contributor Author

I'll take a closer look at the bucket tests and verify what they are testing – if they add value, I'll do the same.

@stuartcarnie
Copy link
Contributor Author

@gavincabbage I'm going to add a follow up task to investigate refactoring these commands so they are testable.

The v1_authorization command was copied from authorization.go and is not testable, as the dependencies are not injected.

Copy link
Contributor

@gavincabbage gavincabbage left a comment

Choose a reason for hiding this comment

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

Great, sounds good @stuartcarnie. I just made a similar call to skip testing something difficult to test until I refactor it to make it testable, so I know how that goes 😅

@stuartcarnie stuartcarnie merged commit ecbb598 into master Oct 29, 2020
@stuartcarnie stuartcarnie deleted the sgc/issues/19765 branch October 29, 2020 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/tooling area/2.x OSS 2.0 related issues and PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add influx v1 auth CLI
2 participants