mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
adds API endpoints to manage OAuth2 Application (list/create/delete) (#10437)
* add API endpoint to create OAuth2 Application. * move endpoint to /user. Add swagger documentations and proper response type. * change json tags to snake_case. add CreateOAuth2ApplicationOptions to swagger docs. * change response status to Created (201) * add methods to list OAuth2 apps and delete an existing OAuth2 app by ID. * add APIFormat convert method and file header * fixed header * hide secret on oauth2 application list * add Created time to API response * add API integration tests for create/list/delete OAuth2 applications. Co-authored-by: techknowlogick <matti@mdranta.net> Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
This commit is contained in:
@@ -8071,6 +8071,89 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/user/applications/oauth2": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"user"
|
||||
],
|
||||
"summary": "List the authenticated user's oauth2 applications",
|
||||
"operationId": "userGetOauth2Application",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "page number of results to return (1-based)",
|
||||
"name": "page",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "page size of results, maximum page size is 50",
|
||||
"name": "limit",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"$ref": "#/responses/OAuth2ApplicationList"
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"user"
|
||||
],
|
||||
"summary": "creates a new OAuth2 application",
|
||||
"operationId": "userCreateOAuth2Application",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/CreateOAuth2ApplicationOptions"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"201": {
|
||||
"$ref": "#/responses/OAuth2Application"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/user/applications/oauth2/{id}": {
|
||||
"delete": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"user"
|
||||
],
|
||||
"summary": "delete an OAuth2 Application",
|
||||
"operationId": "userDeleteOAuth2Application",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": "token to be deleted",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"204": {
|
||||
"$ref": "#/responses/empty"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/user/emails": {
|
||||
"get": {
|
||||
"produces": [
|
||||
@@ -10357,6 +10440,24 @@
|
||||
},
|
||||
"x-go-package": "code.gitea.io/gitea/modules/structs"
|
||||
},
|
||||
"CreateOAuth2ApplicationOptions": {
|
||||
"description": "CreateOAuth2ApplicationOptions holds options to create an oauth2 application",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"x-go-name": "Name"
|
||||
},
|
||||
"redirect_uris": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"x-go-name": "RedirectURIs"
|
||||
}
|
||||
},
|
||||
"x-go-package": "code.gitea.io/gitea/modules/structs"
|
||||
},
|
||||
"CreateOrgOption": {
|
||||
"description": "CreateOrgOption options for creating an organization",
|
||||
"type": "object",
|
||||
@@ -12198,6 +12299,42 @@
|
||||
},
|
||||
"x-go-package": "code.gitea.io/gitea/modules/structs"
|
||||
},
|
||||
"OAuth2Application": {
|
||||
"type": "object",
|
||||
"title": "OAuth2Application represents an OAuth2 application.",
|
||||
"properties": {
|
||||
"client_id": {
|
||||
"type": "string",
|
||||
"x-go-name": "ClientID"
|
||||
},
|
||||
"client_secret": {
|
||||
"type": "string",
|
||||
"x-go-name": "ClientSecret"
|
||||
},
|
||||
"created": {
|
||||
"type": "string",
|
||||
"format": "date-time",
|
||||
"x-go-name": "Created"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"x-go-name": "ID"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"x-go-name": "Name"
|
||||
},
|
||||
"redirect_uris": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"x-go-name": "RedirectURIs"
|
||||
}
|
||||
},
|
||||
"x-go-package": "code.gitea.io/gitea/modules/structs"
|
||||
},
|
||||
"Organization": {
|
||||
"description": "Organization represents an organization",
|
||||
"type": "object",
|
||||
@@ -13689,6 +13826,21 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"OAuth2Application": {
|
||||
"description": "OAuth2Application",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/OAuth2Application"
|
||||
}
|
||||
},
|
||||
"OAuth2ApplicationList": {
|
||||
"description": "OAuth2ApplicationList represents a list of OAuth2 applications.",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/OAuth2Application"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Organization": {
|
||||
"description": "Organization",
|
||||
"schema": {
|
||||
@@ -13971,7 +14123,7 @@
|
||||
"parameterBodies": {
|
||||
"description": "parameterBodies",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/EditBranchProtectionOption"
|
||||
"$ref": "#/definitions/CreateOAuth2ApplicationOptions"
|
||||
}
|
||||
},
|
||||
"redirect": {
|
||||
|
Reference in New Issue
Block a user