feat: add OAuth2 applications (#11197)

* Add database tables for OAuth2 applications

These are applications that will be able to use OAuth2 to get an API key
from Coder.

* Add endpoints for managing OAuth2 applications

These let you add, update, and remove OAuth2 applications.

* Add frontend for managing OAuth2 applications
This commit is contained in:
Asher
2023-12-21 21:38:42 +00:00
committed by GitHub
parent e044d3b752
commit 5cfa34b31e
47 changed files with 4281 additions and 1 deletions
+319
View File
@@ -1122,6 +1122,250 @@
}
}
},
"/oauth2-provider/apps": {
"get": {
"security": [
{
"CoderSessionToken": []
}
],
"produces": ["application/json"],
"tags": ["Enterprise"],
"summary": "Get OAuth2 applications.",
"operationId": "get-oauth2-applications",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/codersdk.OAuth2ProviderApp"
}
}
}
}
},
"post": {
"security": [
{
"CoderSessionToken": []
}
],
"consumes": ["application/json"],
"produces": ["application/json"],
"tags": ["Enterprise"],
"summary": "Create OAuth2 application.",
"operationId": "create-oauth2-application",
"parameters": [
{
"description": "The OAuth2 application to create.",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/codersdk.PostOAuth2ProviderAppRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/codersdk.OAuth2ProviderApp"
}
}
}
}
},
"/oauth2-provider/apps/{app}": {
"get": {
"security": [
{
"CoderSessionToken": []
}
],
"produces": ["application/json"],
"tags": ["Enterprise"],
"summary": "Get OAuth2 application.",
"operationId": "get-oauth2-application",
"parameters": [
{
"type": "string",
"description": "App ID",
"name": "app",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/codersdk.OAuth2ProviderApp"
}
}
}
},
"put": {
"security": [
{
"CoderSessionToken": []
}
],
"consumes": ["application/json"],
"produces": ["application/json"],
"tags": ["Enterprise"],
"summary": "Update OAuth2 application.",
"operationId": "update-oauth2-application",
"parameters": [
{
"type": "string",
"description": "App ID",
"name": "app",
"in": "path",
"required": true
},
{
"description": "Update an OAuth2 application.",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/codersdk.PutOAuth2ProviderAppRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/codersdk.OAuth2ProviderApp"
}
}
}
},
"delete": {
"security": [
{
"CoderSessionToken": []
}
],
"tags": ["Enterprise"],
"summary": "Delete OAuth2 application.",
"operationId": "delete-oauth2-application",
"parameters": [
{
"type": "string",
"description": "App ID",
"name": "app",
"in": "path",
"required": true
}
],
"responses": {
"204": {
"description": "No Content"
}
}
}
},
"/oauth2-provider/apps/{app}/secrets": {
"get": {
"security": [
{
"CoderSessionToken": []
}
],
"produces": ["application/json"],
"tags": ["Enterprise"],
"summary": "Get OAuth2 application secrets.",
"operationId": "get-oauth2-application-secrets",
"parameters": [
{
"type": "string",
"description": "App ID",
"name": "app",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/codersdk.OAuth2ProviderAppSecret"
}
}
}
}
},
"post": {
"security": [
{
"CoderSessionToken": []
}
],
"produces": ["application/json"],
"tags": ["Enterprise"],
"summary": "Create OAuth2 application secret.",
"operationId": "create-oauth2-application-secret",
"parameters": [
{
"type": "string",
"description": "App ID",
"name": "app",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/codersdk.OAuth2ProviderAppSecretFull"
}
}
}
}
}
},
"/oauth2-provider/apps/{app}/secrets/{secretID}": {
"delete": {
"security": [
{
"CoderSessionToken": []
}
],
"tags": ["Enterprise"],
"summary": "Delete OAuth2 application secret.",
"operationId": "delete-oauth2-application-secret",
"parameters": [
{
"type": "string",
"description": "App ID",
"name": "app",
"in": "path",
"required": true
},
{
"type": "string",
"description": "Secret ID",
"name": "secretID",
"in": "path",
"required": true
}
],
"responses": {
"204": {
"description": "No Content"
}
}
}
},
"/organizations": {
"post": {
"security": [
@@ -8442,6 +8686,51 @@
}
}
},
"codersdk.OAuth2ProviderApp": {
"type": "object",
"properties": {
"callback_url": {
"type": "string"
},
"icon": {
"type": "string"
},
"id": {
"type": "string",
"format": "uuid"
},
"name": {
"type": "string"
}
}
},
"codersdk.OAuth2ProviderAppSecret": {
"type": "object",
"properties": {
"client_secret_truncated": {
"type": "string"
},
"id": {
"type": "string",
"format": "uuid"
},
"last_used_at": {
"type": "string"
}
}
},
"codersdk.OAuth2ProviderAppSecretFull": {
"type": "object",
"properties": {
"client_secret_full": {
"type": "string"
},
"id": {
"type": "string",
"format": "uuid"
}
}
},
"codersdk.OAuthConversionResponse": {
"type": "object",
"properties": {
@@ -8672,6 +8961,21 @@
}
}
},
"codersdk.PostOAuth2ProviderAppRequest": {
"type": "object",
"required": ["callback_url", "name"],
"properties": {
"callback_url": {
"type": "string"
},
"icon": {
"type": "string"
},
"name": {
"type": "string"
}
}
},
"codersdk.PprofConfig": {
"type": "object",
"properties": {
@@ -8928,6 +9232,21 @@
}
}
},
"codersdk.PutOAuth2ProviderAppRequest": {
"type": "object",
"required": ["callback_url", "name"],
"properties": {
"callback_url": {
"type": "string"
},
"icon": {
"type": "string"
},
"name": {
"type": "string"
}
}
},
"codersdk.RBACResource": {
"type": "string",
"enum": [