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
+2
View File
@@ -10,6 +10,7 @@ export interface APIKey {
readonly updated_at: string
readonly login_type: LoginType
readonly scope: APIKeyScope
readonly token_name: string
readonly lifetime_seconds: number
}
@@ -224,6 +225,7 @@ export interface CreateTokenRequest {
// This is likely an enum in an external package ("time.Duration")
readonly lifetime: number
readonly scope: APIKeyScope
readonly token_name: string
}
// From codersdk/users.go
+2
View File
@@ -41,6 +41,7 @@ export const MockTokens: TypesGen.APIKey[] = [
login_type: "token",
scope: "all",
lifetime_seconds: 2592000,
token_name: "token-one",
},
{
id: "tBoVE3dqLl",
@@ -52,6 +53,7 @@ export const MockTokens: TypesGen.APIKey[] = [
login_type: "token",
scope: "all",
lifetime_seconds: 2592000,
token_name: "token-two",
},
]