mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-11 02:54:05 +02:00
Add Swagger model annotations and new API routes for OAuth2 authentication management
This commit is contained in:
parent
b58f94acd6
commit
13b7591717
@ -3,6 +3,7 @@
|
||||
|
||||
package structs
|
||||
|
||||
// swagger:model
|
||||
type AuthSourceOption struct {
|
||||
ID int64 `json:"id"`
|
||||
AuthenticationName string `json:"authentication_name" binding:"Required"`
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
package structs
|
||||
|
||||
// CreateUserOption create user options
|
||||
// swagger:model
|
||||
type CreateAuthOauth2Option struct {
|
||||
AuthenticationName string `json:"authentication_name" binding:"Required"`
|
||||
ProviderIconURL string `json:"provider_icon_url"`
|
||||
@ -27,6 +28,7 @@ type CreateAuthOauth2Option struct {
|
||||
}
|
||||
|
||||
// EditUserOption edit user options
|
||||
// swagger:model
|
||||
type EditAuthOauth2Option struct {
|
||||
AuthenticationName string `json:"authentication_name" binding:"Required"`
|
||||
ProviderIconURL string `json:"provider_icon_url"`
|
||||
|
||||
@ -136,7 +136,7 @@ func EditOauthAuth(ctx *context.APIContext) {
|
||||
return
|
||||
}
|
||||
|
||||
form := web.GetForm(ctx).(*api.CreateAuthOauth2Option)
|
||||
form := web.GetForm(ctx).(*api.EditAuthOauth2Option)
|
||||
|
||||
config := &oauth2.Source{
|
||||
Provider: "openidConnect",
|
||||
|
||||
@ -25,7 +25,7 @@ type Source struct {
|
||||
GroupTeamMap string
|
||||
GroupTeamMapRemoval bool
|
||||
RestrictedGroup string
|
||||
SkipLocalTwoFA bool `json:",omitempty"`
|
||||
SkipLocalTwoFA bool
|
||||
|
||||
// reference to the authSource
|
||||
authSource *auth.Source
|
||||
|
||||
203
templates/swagger/v1_json.tmpl
generated
203
templates/swagger/v1_json.tmpl
generated
@ -21,7 +21,7 @@
|
||||
},
|
||||
"version": "{{AppVer | JSEscape}}"
|
||||
},
|
||||
"basePath": "{{AppSubUrl | JSEscape}}/api/v1",
|
||||
"basePath": "/{{AppSubUrl | JSEscape}}/api/v1",
|
||||
"paths": {
|
||||
"/activitypub/user-id/{user-id}": {
|
||||
"get": {
|
||||
@ -472,6 +472,207 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/admin/identity-auth": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"admin"
|
||||
],
|
||||
"summary": "Search authentication sources",
|
||||
"operationId": "adminSearchAuth",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "page number of results to return (1-based)",
|
||||
"name": "page",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "page size of results",
|
||||
"name": "limit",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "SearchResults of authentication sources",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/AuthOauth2Option"
|
||||
}
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"$ref": "#/responses/forbidden"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/admin/identity-auth/oauth": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"admin"
|
||||
],
|
||||
"summary": "Search OAuth2 authentication sources",
|
||||
"operationId": "adminSearchOauth2Auth",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "page number of results to return (1-based)",
|
||||
"name": "page",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "page size of results",
|
||||
"name": "limit",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "SearchResults of OAuth2 authentication sources",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/AuthOauth2Option"
|
||||
}
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"$ref": "#/responses/forbidden"
|
||||
}
|
||||
}
|
||||
},
|
||||
"put": {
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"admin"
|
||||
],
|
||||
"summary": "Create an OAuth2 authentication source",
|
||||
"operationId": "adminCreateOauth2Auth",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/CreateAuthOauth2Option"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "OAuth2 authentication source created successfully"
|
||||
},
|
||||
"400": {
|
||||
"$ref": "#/responses/error"
|
||||
},
|
||||
"403": {
|
||||
"$ref": "#/responses/forbidden"
|
||||
},
|
||||
"422": {
|
||||
"$ref": "#/responses/validationError"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/admin/identity-auth/oauth/{id}": {
|
||||
"delete": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"admin"
|
||||
],
|
||||
"summary": "Delete an OAuth2 authentication source",
|
||||
"operationId": "adminDeleteOauth2Auth",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": "authentication source ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OAuth2 authentication source deleted successfully"
|
||||
},
|
||||
"403": {
|
||||
"$ref": "#/responses/forbidden"
|
||||
},
|
||||
"404": {
|
||||
"$ref": "#/responses/notFound"
|
||||
},
|
||||
"422": {
|
||||
"$ref": "#/responses/validationError"
|
||||
}
|
||||
}
|
||||
},
|
||||
"patch": {
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"admin"
|
||||
],
|
||||
"summary": "Update an OAuth2 authentication source",
|
||||
"operationId": "adminEditOauth2Auth",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": "authentication source ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/CreateAuthOauth2Option"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "OAuth2 authentication source updated successfully"
|
||||
},
|
||||
"400": {
|
||||
"$ref": "#/responses/error"
|
||||
},
|
||||
"403": {
|
||||
"$ref": "#/responses/forbidden"
|
||||
},
|
||||
"404": {
|
||||
"$ref": "#/responses/notFound"
|
||||
},
|
||||
"422": {
|
||||
"$ref": "#/responses/validationError"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/admin/orgs": {
|
||||
"get": {
|
||||
"produces": [
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user