feat: add personal access tokens for service users (#2974)

* feat: add machine tokens

* fix test

* rename to pat

* fix merge and tests

* fix scopes

* fix migration version

* fix test

* Update internal/repository/user/personal_access_token.go

Co-authored-by: Fabi <38692350+fgerschwiler@users.noreply.github.com>

Co-authored-by: Fabi <38692350+fgerschwiler@users.noreply.github.com>
This commit is contained in:
Livio Amstutz
2022-02-08 09:37:28 +01:00
committed by GitHub
parent 3bf9adece5
commit 699fdaf68e
32 changed files with 1838 additions and 30 deletions

View File

@@ -623,13 +623,62 @@ Generates a new machine key, details should be stored after return
> **rpc** RemoveMachineKey([RemoveMachineKeyRequest](#removemachinekeyrequest))
[RemoveMachineKeyResponse](#removemachinekeyresponse)
Removed a machine key
Removes a machine key
DELETE: /users/{user_id}/keys/{key_id}
### GetPersonalAccessTokenByIDs
> **rpc** GetPersonalAccessTokenByIDs([GetPersonalAccessTokenByIDsRequest](#getpersonalaccesstokenbyidsrequest))
[GetPersonalAccessTokenByIDsResponse](#getpersonalaccesstokenbyidsresponse)
Returns a personal access token of a (machine) user
GET: /users/{user_id}/pats/{token_id}
### ListPersonalAccessTokens
> **rpc** ListPersonalAccessTokens([ListPersonalAccessTokensRequest](#listpersonalaccesstokensrequest))
[ListPersonalAccessTokensResponse](#listpersonalaccesstokensresponse)
Returns all personal access tokens of a (machine) user which match the query
Limit should always be set, there is a default limit set by the service
POST: /users/{user_id}/pats/_search
### AddPersonalAccessToken
> **rpc** AddPersonalAccessToken([AddPersonalAccessTokenRequest](#addpersonalaccesstokenrequest))
[AddPersonalAccessTokenResponse](#addpersonalaccesstokenresponse)
Generates a new personal access token for a machine user, details should be stored after return
POST: /users/{user_id}/pats
### RemovePersonalAccessToken
> **rpc** RemovePersonalAccessToken([RemovePersonalAccessTokenRequest](#removepersonalaccesstokenrequest))
[RemovePersonalAccessTokenResponse](#removepersonalaccesstokenresponse)
Removes a personal access token
DELETE: /users/{user_id}/pats/{token_id}
### ListHumanLinkedIDPs
> **rpc** ListHumanLinkedIDPs([ListHumanLinkedIDPsRequest](#listhumanlinkedidpsrequest))
@@ -3431,6 +3480,31 @@ This is an empty request
### AddPersonalAccessTokenRequest
| Field | Type | Description | Validation |
| ----- | ---- | ----------- | ----------- |
| user_id | string | - | string.min_len: 1<br /> |
| expiration_date | google.protobuf.Timestamp | - | |
### AddPersonalAccessTokenResponse
| Field | Type | Description | Validation |
| ----- | ---- | ----------- | ----------- |
| token_id | string | - | |
| token | string | - | |
| details | zitadel.v1.ObjectDetails | - | |
### AddProjectGrantMemberRequest
@@ -4816,6 +4890,29 @@ This is an empty request
### GetPersonalAccessTokenByIDsRequest
| Field | Type | Description | Validation |
| ----- | ---- | ----------- | ----------- |
| user_id | string | - | string.min_len: 1<br /> string.max_len: 200<br /> |
| token_id | string | - | string.min_len: 1<br /> string.max_len: 200<br /> |
### GetPersonalAccessTokenByIDsResponse
| Field | Type | Description | Validation |
| ----- | ---- | ----------- | ----------- |
| token | zitadel.user.v1.PersonalAccessToken | - | |
### GetPreviewLabelPolicyRequest
This is an empty request
@@ -5572,6 +5669,30 @@ This is an empty request
### ListPersonalAccessTokensRequest
| Field | Type | Description | Validation |
| ----- | ---- | ----------- | ----------- |
| user_id | string | - | string.min_len: 1<br /> string.max_len: 200<br /> |
| query | zitadel.v1.ListQuery | list limitations and ordering | |
### ListPersonalAccessTokensResponse
| Field | Type | Description | Validation |
| ----- | ---- | ----------- | ----------- |
| details | zitadel.v1.ListDetails | - | |
| result | repeated zitadel.user.v1.PersonalAccessToken | - | |
### ListProjectChangesRequest
@@ -6525,6 +6646,29 @@ This is an empty response
### RemovePersonalAccessTokenRequest
| Field | Type | Description | Validation |
| ----- | ---- | ----------- | ----------- |
| user_id | string | - | string.min_len: 1<br /> string.max_len: 200<br /> |
| token_id | string | - | string.min_len: 1<br /> string.max_len: 200<br /> |
### RemovePersonalAccessTokenResponse
| Field | Type | Description | Validation |
| ----- | ---- | ----------- | ----------- |
| details | zitadel.v1.ObjectDetails | - | |
### RemoveProjectGrantMemberRequest

View File

@@ -213,6 +213,20 @@ this query is always equals
### PersonalAccessToken
| Field | Type | Description | Validation |
| ----- | ---- | ----------- | ----------- |
| id | string | - | |
| details | zitadel.v1.ObjectDetails | - | |
| expiration_date | google.protobuf.Timestamp | - | |
| scopes | repeated string | - | |
### Phone