feat: add ability to name tokens (#6365)

* add tokens switch

* reorged TokensPage

* using Trans component for description

* using Trans component on DeleteDialog

* add owner col

* simplify hook return

* lint

* type for response

* added flag for name

* fixed auth

* lint, prettier, tests

* added unique index for login type token

* remove tokens by name

* better check for unique constraint

* docs

* test: Fix dbfake to insert token name

* fix doc tests

* Update cli/tokens.go

Co-authored-by: Steven Masley <Emyrk@users.noreply.github.com>

* Update coderd/database/migrations/000102_add_apikey_name.down.sql

Co-authored-by: Steven Masley <Emyrk@users.noreply.github.com>

* add more specificity to IsUniqueViolation check

* fix tests

* Fix AutorizeAllEndpoints

* rename migration

---------

Co-authored-by: Steven Masley <stevenmasley@coder.com>
Co-authored-by: Steven Masley <Emyrk@users.noreply.github.com>
This commit is contained in:
Kira Pilot
2023-03-02 09:39:38 -08:00
committed by GitHub
co-authored by Steven Masley Steven Masley
parent e3a4861e93
commit 71d1e63af0
37 changed files with 447 additions and 63 deletions
+1 -1
View File
@@ -22,7 +22,7 @@ Get Started:
$ coder tokens rm WuoWs4ZsMX
Commands:
create Create a tokens
create Create a token
list List tokens
remove Delete a token
+2 -1
View File
@@ -1,4 +1,4 @@
Create a tokens
Create a token
Usage:
coder tokens create [flags]
@@ -7,6 +7,7 @@ Flags:
-h, --help help for create
--lifetime duration Specify a duration for the lifetime of the token.
Consumes $CODER_TOKEN_LIFETIME (default 720h0m0s)
-n, --name string Specify a human-readable name.
Global Flags:
--global-config coder Path to the global coder config directory.
+3 -3
View File
@@ -9,9 +9,9 @@ Aliases:
Flags:
-a, --all Specifies whether all users' tokens will be listed or not (must have
Owner role to see all tokens).
-c, --column strings Columns to display in table output. Available columns: id, last used,
expires at, created at, owner (default [id,last used,expires
at,created at])
-c, --column strings Columns to display in table output. Available columns: id, name, last
used, expires at, created at, owner (default [id,name,last
used,expires at,created at])
-h, --help help for list
-o, --output string Output format. Available formats: table, json (default "table")
+1 -1
View File
@@ -1,7 +1,7 @@
Delete a token
Usage:
coder tokens remove [id] [flags]
coder tokens remove [name] [flags]
Aliases:
remove, rm