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
+5 -5
View File
@@ -28,8 +28,8 @@ coder tokens [flags]
## Subcommands
| Name | Purpose |
| -------------------------------------------- | --------------- |
| [<code>create</code>](./coder_tokens_create) | Create a tokens |
| [<code>list</code>](./coder_tokens_list) | List tokens |
| [<code>remove</code>](./coder_tokens_remove) | Delete a token |
| Name | Purpose |
| -------------------------------------------- | -------------- |
| [<code>create</code>](./coder_tokens_create) | Create a token |
| [<code>list</code>](./coder_tokens_list) | List tokens |
| [<code>remove</code>](./coder_tokens_remove) | Delete a token |
+8 -1
View File
@@ -2,7 +2,7 @@
# coder tokens create
Create a tokens
Create a token
## Usage
@@ -20,3 +20,10 @@ Specify a duration for the lifetime of the token.
| --- | --- |
| Consumes | <code>$CODER_TOKEN_LIFETIME</code> |
| Default | <code>720h0m0s</code> |
### --name, -n
Specify a human-readable name.
<br/>
| | |
| --- | --- |
+2 -2
View File
@@ -22,11 +22,11 @@ Specifies whether all users' tokens will be listed or not (must have Owner role
### --column, -c
Columns to display in table output. Available columns: id, last used, expires at, created at, owner
Columns to display in table output. Available columns: id, name, last used, expires at, created at, owner
<br/>
| | |
| --- | --- |
| Default | <code>[id,last used,expires at,created at]</code> |
| Default | <code>[id,name,last used,expires at,created at]</code> |
### --output, -o
+1 -1
View File
@@ -7,5 +7,5 @@ Delete a token
## Usage
```console
coder tokens remove [id] [flags]
coder tokens remove [name] [flags]
```