feat: implement oauth2 RFC 7009 token revocation endpoint (#20362)

Adds RFC 7009 token revocation endpoint
This commit is contained in:
Steven Masley
2025-10-22 15:18:42 -05:00
committed by GitHub
parent 5f97ad0988
commit 4bd7c7b7e0
17 changed files with 558 additions and 63 deletions
+45 -4
View File
@@ -809,7 +809,8 @@ curl -X GET http://coder-server:8080/api/v2/oauth2-provider/apps \
"endpoints": {
"authorization": "string",
"device_authorization": "string",
"token": "string"
"token": "string",
"token_revoke": "string"
},
"icon": "string",
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
@@ -836,6 +837,7 @@ Status Code **200**
| `»» authorization` | string | false | | |
| `»» device_authorization` | string | false | | Device authorization is optional. |
| `»» token` | string | false | | |
| `»» token_revoke` | string | false | | |
| `» icon` | string | false | | |
| `» id` | string(uuid) | false | | |
| `» name` | string | false | | |
@@ -882,7 +884,8 @@ curl -X POST http://coder-server:8080/api/v2/oauth2-provider/apps \
"endpoints": {
"authorization": "string",
"device_authorization": "string",
"token": "string"
"token": "string",
"token_revoke": "string"
},
"icon": "string",
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
@@ -927,7 +930,8 @@ curl -X GET http://coder-server:8080/api/v2/oauth2-provider/apps/{app} \
"endpoints": {
"authorization": "string",
"device_authorization": "string",
"token": "string"
"token": "string",
"token_revoke": "string"
},
"icon": "string",
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
@@ -984,7 +988,8 @@ curl -X PUT http://coder-server:8080/api/v2/oauth2-provider/apps/{app} \
"endpoints": {
"authorization": "string",
"device_authorization": "string",
"token": "string"
"token": "string",
"token_revoke": "string"
},
"icon": "string",
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
@@ -1500,6 +1505,42 @@ curl -X POST http://coder-server:8080/api/v2/oauth2/register \
|--------|--------------------------------------------------------------|-------------|--------------------------------------------------------------------------------------------------|
| 201 | [Created](https://tools.ietf.org/html/rfc7231#section-6.3.2) | Created | [codersdk.OAuth2ClientRegistrationResponse](schemas.md#codersdkoauth2clientregistrationresponse) |
## Revoke OAuth2 tokens (RFC 7009)
### Code samples
```shell
# Example request using curl
curl -X POST http://coder-server:8080/api/v2/oauth2/revoke \
```
`POST /oauth2/revoke`
> Body parameter
```yaml
client_id: string
token: string
token_type_hint: string
```
### Parameters
| Name | In | Type | Required | Description |
|---------------------|------|--------|----------|-------------------------------------------------------|
| `body` | body | object | true | |
| `» client_id` | body | string | true | Client ID for authentication |
| `» token` | body | string | true | The token to revoke |
| `» token_type_hint` | body | string | false | Hint about token type (access_token or refresh_token) |
### Responses
| Status | Meaning | Description | Schema |
|--------|---------------------------------------------------------|----------------------------|--------|
| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | Token successfully revoked | |
## OAuth2 token exchange
### Code samples
+5 -2
View File
@@ -5272,7 +5272,8 @@ Only certain features set these fields: - FeatureManagedAgentLimit|
{
"authorization": "string",
"device_authorization": "string",
"token": "string"
"token": "string",
"token_revoke": "string"
}
```
@@ -5283,6 +5284,7 @@ Only certain features set these fields: - FeatureManagedAgentLimit|
| `authorization` | string | false | | |
| `device_authorization` | string | false | | Device authorization is optional. |
| `token` | string | false | | |
| `token_revoke` | string | false | | |
## codersdk.OAuth2AuthorizationServerMetadata
@@ -5594,7 +5596,8 @@ Only certain features set these fields: - FeatureManagedAgentLimit|
"endpoints": {
"authorization": "string",
"device_authorization": "string",
"token": "string"
"token": "string",
"token_revoke": "string"
},
"icon": "string",
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",