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: new recovery subcommand allows creating recovery user/token #22590

Merged
merged 6 commits into from
Oct 6, 2021

Conversation

lesam
Copy link
Contributor

@lesam lesam commented Sep 28, 2021

Closes #12051

@lesam lesam force-pushed the recovery-token branch 2 times, most recently from b5b6e5b to 8ae3f28 Compare September 28, 2021 15:28
Copy link
Contributor

@danxmoran danxmoran left a comment

Choose a reason for hiding this comment

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

Didn't review fully yet since my question about command names could cause refactoring.

Another thought I had: I've previously wished for an influxd setup command that would do the same thing as influx setup/influxd upgrade. If that command supported something like a --force or --ignore-existing flag, would implementing that be another way to achieve this functionality? Having it could help us simplify a piece of our DockerHub build's entrypoint script.

cmd/influxd/inspect/auth/auth.go Outdated Show resolved Hide resolved
cmd/influxd/inspect/auth/auth.go Outdated Show resolved Hide resolved
@lesam
Copy link
Contributor Author

lesam commented Oct 4, 2021

Another thought I had: I've previously wished for an influxd setup command that would do the same thing as influx setup/influxd upgrade. If that command supported something like a --force or --ignore-existing flag, would implementing that be another way to achieve this functionality? Having it could help us simplify a piece of our DockerHub build's entrypoint script.

I thought about just calling the same code we use for setup, but that seemed more complicated for users since then they need to know whether they want to recreate buckets and orgs, or just re-add an operator token to an existing user.

I feel like 'add/list user' and 'add operator token' being separate would be a great idea though - then if the user remembers their username they can just add a new token and they're up and running (they can use the new operator token to reset their password). If they're really sunk they can list users or even add a new one.

Maybe @russorat should comment?

@lesam lesam force-pushed the recovery-token branch 2 times, most recently from ee62a8e to 6e6d565 Compare October 6, 2021 12:54
@lesam lesam requested a review from danxmoran October 6, 2021 12:54
@lesam
Copy link
Contributor Author

lesam commented Oct 6, 2021

Changed to have a user, org, and auth subcommands. Most users will want just the auth subcommand to get an admin token for a known username and get back in business. user is for if all the users got deleted somehow, org similarly for if all the orgs got deleted somehow.

Because there are so many of these, I decided to add a new top-level influxd recovery-cli subcommand instead of putting everything under influxd inspect

@lesam
Copy link
Contributor Author

lesam commented Oct 6, 2021

New command help:

➜  influxdb-2.x git:(recovery-token) ✗ ./bin/darwin/influxd recovery-cli -h
Subset of commands similar to influx cli but usable on a halted local database without authentication

Usage:
  influxd recovery-cli [flags]
  influxd recovery-cli [command]

Available Commands:
  auth        On-disk authorization management commands, for recovery
  org         On-disk organization management commands, for recovery
  user        On-disk user management commands, for recovery

Flags:
  -h, --help   help for recovery-cli

Use "influxd recovery-cli [command] --help" for more information about a command.
➜  influxdb-2.x git:(recovery-token) ✗ ./bin/darwin/influxd recovery-cli auth -h
On-disk authorization management commands, for recovery

Usage:
  influxd recovery-cli auth [flags]
  influxd recovery-cli auth [command]

Available Commands:
  create-operator Create new operator token for a user
  list            List authorizations

Flags:
  -h, --help   help for auth

Use "influxd recovery-cli auth [command] --help" for more information about a command.
➜  influxdb-2.x git:(recovery-token) ✗ ./bin/darwin/influxd recovery-cli org -h
On-disk organization management commands, for recovery

Usage:
  influxd recovery-cli org [flags]
  influxd recovery-cli org [command]

Available Commands:
  create      Create new org
  list        List organizations

Flags:
  -h, --help   help for org

Use "influxd recovery-cli org [command] --help" for more information about a command.
➜  influxdb-2.x git:(recovery-token) ✗ ./bin/darwin/influxd recovery-cli user -h
On-disk user management commands, for recovery

Usage:
  influxd recovery-cli user [flags]
  influxd recovery-cli user [command]

Available Commands:
  create      Create new user
  list        List users

Flags:
  -h, --help   help for user

Use "influxd recovery-cli user [command] --help" for more information about a command.

@lesam lesam force-pushed the recovery-token branch 2 times, most recently from 600c662 to c825e62 Compare October 6, 2021 13:07
cmd/influxd/recovery/auth/auth.go Outdated Show resolved Hide resolved
cmd/influxd/recovery/auth/auth.go Outdated Show resolved Hide resolved
cmd/influxd/recovery/auth/auth.go Outdated Show resolved Hide resolved
cmd/influxd/recovery/auth/auth.go Outdated Show resolved Hide resolved
cmd/influxd/recovery/auth/auth.go Outdated Show resolved Hide resolved
cmd/influxd/recovery/recovery.go Outdated Show resolved Hide resolved
cmd/influxd/recovery/user/user.go Outdated Show resolved Hide resolved
cmd/influxd/recovery/user/user.go Outdated Show resolved Hide resolved
cmd/influxd/recovery/user/user.go Show resolved Hide resolved
internal/tabwriter/tabwriter.go Outdated Show resolved Hide resolved
Co-authored-by: Daniel Moran <danxmoran@gmail.com>
@lesam lesam changed the title feat: inspect allows creating recovery user/token feat: new recovery subcommand allows creating recovery user/token Oct 6, 2021
@lesam lesam requested a review from danxmoran October 6, 2021 15:47
@@ -2,6 +2,104 @@ module github.com/influxdata/influxdb/v2

go 1.17

require (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure why go mod tidy decided to re-arrange things like this.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure either, but I've seen it before since the 1.17 upgrade. I've been merging them back together and then go mod tidy-ing to re-sort, not sure if it's worth continuing to fight it

@@ -430,8 +430,8 @@ github.com/influxdata/flux v0.133.0 h1:U1zYP5qXjh6esGOMc4d8efkTgqNORDc9KRWc6NIZs
github.com/influxdata/flux v0.133.0/go.mod h1:RzogdNsdZoyDAw53BwLrhqyrVI7eT0IKEWW2UjAvTiw=
github.com/influxdata/httprouter v1.3.1-0.20191122104820-ee83e2772f69 h1:WQsmW0fXO4ZE/lFGIE84G6rIV5SJN3P3sjIXAP1a8eU=
github.com/influxdata/httprouter v1.3.1-0.20191122104820-ee83e2772f69/go.mod h1:pwymjR6SrP3gD3pRj9RJwdl1j5s3doEEV8gS4X9qSzA=
github.com/influxdata/influx-cli/v2 v2.1.1-0.20210924182719-d0640ad6c4d4 h1:brA9egXkPF/ZGKbPu2Vt7GXJ4cv5Oo6eSff4ykhnwTE=
github.com/influxdata/influx-cli/v2 v2.1.1-0.20210924182719-d0640ad6c4d4/go.mod h1:piIN/dAOSRqdZZc2sHO7CORuWUQ0UXdNrjugF3cEr8k=
github.com/influxdata/influx-cli/v2 v2.1.1-0.20211006152725-857e2b356cc0 h1:2tFXbj1A3pRpuccDUEro4ZZYVAmAJgFha60Oz4+kSCE=
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only the expected change in go.sum though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow user to reset password
2 participants