You've already forked woodpecker
mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2026-06-03 16:35:37 +02:00
@@ -665,7 +665,7 @@ const docTemplate = `{
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/Forge"
|
||||
"$ref": "#/definitions/ForgeWithOAuthClientSecret"
|
||||
}
|
||||
}
|
||||
],
|
||||
@@ -774,7 +774,7 @@ const docTemplate = `{
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/Forge"
|
||||
"$ref": "#/definitions/ForgeWithOAuthClientSecret"
|
||||
}
|
||||
}
|
||||
],
|
||||
@@ -4809,6 +4809,37 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"ForgeWithOAuthClientSecret": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"additional_options": {
|
||||
"type": "object",
|
||||
"additionalProperties": {}
|
||||
},
|
||||
"client": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"oauth_client_secret": {
|
||||
"type": "string"
|
||||
},
|
||||
"oauth_host": {
|
||||
"description": "public url for oauth if different from url",
|
||||
"type": "string"
|
||||
},
|
||||
"skip_verify": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"type": {
|
||||
"$ref": "#/definitions/model.ForgeType"
|
||||
},
|
||||
"url": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"LogEntry": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
+9
-15
@@ -93,19 +93,13 @@ func GetForge(c *gin.Context) {
|
||||
// @Produce json
|
||||
// @Success 200 {object} Forge
|
||||
// @Tags Forges
|
||||
// @Param Authorization header string true "Insert your personal access token" default(Bearer <personal access token>)
|
||||
// @Param forgeId path int true "the forge's id"
|
||||
// @Param forgeData body Forge true "the forge's data"
|
||||
// @Param Authorization header string true "Insert your personal access token" default(Bearer <personal access token>)
|
||||
// @Param forgeId path int true "the forge's id"
|
||||
// @Param forgeData body ForgeWithOAuthClientSecret true "the forge's data"
|
||||
func PatchForge(c *gin.Context) {
|
||||
_store := store.FromContext(c)
|
||||
|
||||
// use this struct to allow updating the client secret
|
||||
type ForgeWithClientSecret struct {
|
||||
model.Forge
|
||||
ClientSecret string `json:"client_secret"`
|
||||
}
|
||||
|
||||
in := &ForgeWithClientSecret{}
|
||||
in := &model.ForgeWithOAuthClientSecret{}
|
||||
err := c.Bind(in)
|
||||
if err != nil {
|
||||
c.AbortWithStatus(http.StatusBadRequest)
|
||||
@@ -129,8 +123,8 @@ func PatchForge(c *gin.Context) {
|
||||
forge.OAuthHost = in.OAuthHost
|
||||
forge.SkipVerify = in.SkipVerify
|
||||
forge.AdditionalOptions = in.AdditionalOptions
|
||||
if in.ClientSecret != "" {
|
||||
forge.OAuthClientSecret = in.ClientSecret
|
||||
if in.OAuthClientSecret != "" {
|
||||
forge.OAuthClientSecret = in.OAuthClientSecret
|
||||
}
|
||||
|
||||
err = _store.ForgeUpdate(forge)
|
||||
@@ -150,10 +144,10 @@ func PatchForge(c *gin.Context) {
|
||||
// @Produce json
|
||||
// @Success 200 {object} Forge
|
||||
// @Tags Forges
|
||||
// @Param Authorization header string true "Insert your personal access token" default(Bearer <personal access token>)
|
||||
// @Param forge body Forge true "the forge's data (only 'name' and 'no_schedule' are read)"
|
||||
// @Param Authorization header string true "Insert your personal access token" default(Bearer <personal access token>)
|
||||
// @Param forge body ForgeWithOAuthClientSecret true "the forge's data (only 'name' and 'no_schedule' are read)"
|
||||
func PostForge(c *gin.Context) {
|
||||
in := &model.Forge{}
|
||||
in := &model.ForgeWithOAuthClientSecret{}
|
||||
err := c.Bind(in)
|
||||
if err != nil {
|
||||
c.String(http.StatusBadRequest, err.Error())
|
||||
|
||||
@@ -52,3 +52,9 @@ func (f *Forge) PublicCopy() *Forge {
|
||||
|
||||
return forge
|
||||
}
|
||||
|
||||
// ForgeWithOAuthClientSecret allows to update the client secret.
|
||||
type ForgeWithOAuthClientSecret struct {
|
||||
Forge
|
||||
OAuthClientSecret string `json:"oauth_client_secret"`
|
||||
} // @name ForgeWithOAuthClientSecret
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
<InputField v-slot="{ id }" :label="$t('oauth_client_secret')">
|
||||
<TextField
|
||||
:id="id"
|
||||
v-model="forge.client_secret"
|
||||
v-model="forge.oauth_client_secret"
|
||||
:placeholder="isNew ? '' : $t('leave_empty_to_keep_current_value')"
|
||||
:required="isNew"
|
||||
/>
|
||||
@@ -263,7 +263,6 @@ const oauthAppForgeUrl = computed(() => {
|
||||
case 'forgejo':
|
||||
return `${forgeUrl}/user/settings/applications`;
|
||||
case 'bitbucket':
|
||||
return `${forgeUrl}/account/settings/app-passwords`;
|
||||
case 'bitbucket-dc':
|
||||
return `${forgeUrl}/account/settings/app-passwords`;
|
||||
default:
|
||||
|
||||
@@ -5,7 +5,7 @@ export interface Forge {
|
||||
type: ForgeType;
|
||||
url: string;
|
||||
client?: string;
|
||||
client_secret?: string;
|
||||
oauth_client_secret?: string;
|
||||
skip_verify?: boolean;
|
||||
oauth_host?: string;
|
||||
additional_options?: Record<string, unknown>;
|
||||
|
||||
Reference in New Issue
Block a user