summaryrefslogtreecommitdiffstats
path: root/templates/webhook
diff options
context:
space:
mode:
authoroliverpool <git@olivier.pfad.fr>2024-04-08 17:51:39 +0200
committeroliverpool <git@olivier.pfad.fr>2024-04-16 08:59:55 +0200
commit36f05e6f4e711db0da888584c66ec3f3a3d20749 (patch)
tree5bd4274741a9f4faf1eb6c14c5261eb8ccf7a65d /templates/webhook
parentwebhook: sourcehut_builds: prefill sr.ht as defaults (diff)
downloadforgejo-36f05e6f4e711db0da888584c66ec3f3a3d20749.tar.xz
forgejo-36f05e6f4e711db0da888584c66ec3f3a3d20749.zip
webhook: sourcehut_builds: ask for access_token instead of authorization_header
Diffstat (limited to 'templates/webhook')
-rw-r--r--templates/webhook/new/sourcehut_builds.tmpl6
-rw-r--r--templates/webhook/shared-settings.tmpl19
2 files changed, 17 insertions, 8 deletions
diff --git a/templates/webhook/new/sourcehut_builds.tmpl b/templates/webhook/new/sourcehut_builds.tmpl
index e18b828f8d..3bcbe1bf6e 100644
--- a/templates/webhook/new/sourcehut_builds.tmpl
+++ b/templates/webhook/new/sourcehut_builds.tmpl
@@ -29,5 +29,11 @@
<span class="help">{{ctx.Locale.Tr "repo.settings.sourcehut_builds.secrets_helper"}}</span>
</div>
</div>
+ <!-- Access Token -->
+ <div class="field required {{if .Err_AccessToken}}error{{end}}">
+ <label for="access_token">{{ctx.Locale.Tr "form.AccessToken"}}</label>
+ <input id="access_token" name="access_token" type="password" value="{{.Webhook.HeaderAuthorizationTrimPrefix "Bearer "}}" required>
+ <span class="help">{{ctx.Locale.Tr "repo.settings.sourcehut_builds.access_token_helper" "https://meta.sr.ht/oauth2/personal-token?grants=builds.sr.ht/JOBS:RW" "https://meta.sr.ht/oauth2/personal-token?grants=builds.sr.ht/JOBS:RW+builds.sr.ht/SECRETS:RO"}}</span>
+ </div>
{{template "webhook/shared-settings" .}}
</form>
diff --git a/templates/webhook/shared-settings.tmpl b/templates/webhook/shared-settings.tmpl
index 0a39643260..f2724f25e2 100644
--- a/templates/webhook/shared-settings.tmpl
+++ b/templates/webhook/shared-settings.tmpl
@@ -258,14 +258,17 @@
<span class="help">{{ctx.Locale.Tr "repo.settings.branch_filter_desc"}}</span>
</div>
-<!-- Authorization Header -->
-<div class="field{{if eq .HookType "matrix"}} required{{end}} {{if .Err_AuthorizationHeader}}error{{end}}">
- <label for="authorization_header">{{ctx.Locale.Tr "repo.settings.authorization_header"}}</label>
- <input id="authorization_header" name="authorization_header" type="text" value="{{.Webhook.HeaderAuthorization}}"{{if eq .HookType "matrix"}} placeholder="Bearer $access_token" required{{end}}>
- {{if ne .HookType "matrix"}}{{/* Matrix doesn't make the authorization optional but it is implied by the help string, should be changed.*/}}
- <span class="help">{{ctx.Locale.Tr "repo.settings.authorization_header_desc" ("<code>Bearer token123456</code>, <code>Basic YWxhZGRpbjpvcGVuc2VzYW1l</code>" | SafeHTML)}}</span>
- {{end}}
-</div>
+{{$skipAuthorizationHeader := (eq .HookType "sourcehut_builds")}}
+{{if not $skipAuthorizationHeader}}
+ <!-- Authorization Header -->
+ <div class="field{{if eq .HookType "matrix"}} required{{end}} {{if .Err_AuthorizationHeader}}error{{end}}">
+ <label for="authorization_header">{{ctx.Locale.Tr "repo.settings.authorization_header"}}</label>
+ <input id="authorization_header" name="authorization_header" type="text" value="{{.Webhook.HeaderAuthorization}}"{{if eq .HookType "matrix"}} placeholder="Bearer $access_token" required{{end}}>
+ {{if ne .HookType "matrix"}}{{/* Matrix doesn't make the authorization optional but it is implied by the help string, should be changed.*/}}
+ <span class="help">{{ctx.Locale.Tr "repo.settings.authorization_header_desc" ("<code>Bearer token123456</code>, <code>Basic YWxhZGRpbjpvcGVuc2VzYW1l</code>" | SafeHTML)}}</span>
+ {{end}}
+ </div>
+{{end}}
<div class="divider"></div>