Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add API endpoints to manage OAuth2 Application (list/create/delete) #10437

Merged
merged 15 commits into from
Feb 29, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
change json tags to snake_case. add CreateOAuth2ApplicationOptions to…
… swagger docs.
  • Loading branch information
Gustavo Marin committed Feb 25, 2020
commit a5ad56d9300e80ea48dc3db29ad3ed6874c239de
9 changes: 4 additions & 5 deletions modules/structs/user_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,16 @@ type CreateAccessTokenOption struct {
}

// CreateOAuth2ApplicationOptions holds options to create an oauth2 application
// swagger:parameters userCreateOAuth2Application
type CreateOAuth2ApplicationOptions struct {
Name string `json:"name" binding:"Required"`
RedirectURIs []string `json:"redirect-uris" binding:"Required"`
RedirectURIs []string `json:"redirect_uris" binding:"Required"`
}

// OAuth2Application represents an OAuth2 application.
// swagger:response OAuth2Application
type OAuth2Application struct {
Name string `json:"name"`
ClientID string `json:"client-id"`
ClientSecret string `json:"client-secret"`
RedirectURIs []string `json:"redirect-uris"`
ClientID string `json:"client_id"`
ClientSecret string `json:"client_secret"`
RedirectURIs []string `json:"redirect_uris"`
}
3 changes: 3 additions & 0 deletions routers/api/v1/swagger/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,7 @@ type swaggerParameterBodies struct {

// in:body
EditBranchProtectionOption api.EditBranchProtectionOption

// in:body
CreateOAuth2ApplicationOptions api.CreateOAuth2ApplicationOptions
}
7 changes: 6 additions & 1 deletion routers/api/v1/user/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,17 @@ func DeleteAccessToken(ctx *context.APIContext) {

// CreateOauth2Application is the handler to create a new OAuth2 Application for the authenticated user
func CreateOauth2Application(ctx *context.APIContext, data api.CreateOAuth2ApplicationOptions) {
// swagger:operation POST /user/applications/oauth2 userCreateOAuth2Application
// swagger:operation POST /user/applications/oauth2 user userCreateOAuth2Application
// ---
// summary: creates a new OAuth2 application
// produces:
// - application/json
// parameters:
// - name: body
// in: body
// required: true
// schema:
// "$ref": "#/definitions/CreateOAuth2ApplicationOptions"
// responses:
// "200":
// "$ref": "#/responses/OAuth2Application"
Expand Down
39 changes: 35 additions & 4 deletions templates/swagger/v1_json.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -8064,8 +8064,21 @@
"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": {
"200": {
"$ref": "#/responses/OAuth2Application"
Expand Down Expand Up @@ -10359,6 +10372,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",
Expand Down Expand Up @@ -12204,19 +12235,19 @@
"type": "object",
"title": "OAuth2Application represents an OAuth2 application.",
"properties": {
"client-id": {
"client_id": {
"type": "string",
"x-go-name": "ClientID"
},
"client-secret": {
"client_secret": {
"type": "string",
"x-go-name": "ClientSecret"
},
"name": {
"type": "string",
"x-go-name": "Name"
},
"redirect-uris": {
"redirect_uris": {
"type": "array",
"items": {
"type": "string"
Expand Down Expand Up @@ -14005,7 +14036,7 @@
"parameterBodies": {
"description": "parameterBodies",
"schema": {
"$ref": "#/definitions/EditBranchProtectionOption"
"$ref": "#/definitions/CreateOAuth2ApplicationOptions"
This conversation was marked as resolved.
Show resolved Hide resolved
}
},
"redirect": {
Expand Down