Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-11-24 10:46:10 +01:00
forgejo/templates/webhook/shared-settings.tmpl

194 lines
8.9 KiB
Go HTML Template
Raw Normal View History

{{$isNew:=or .PageIsSettingsHooksNew .PageIsAdminDefaultHooksNew .PageIsAdminSystemHooksNew}}
2014-08-24 14:59:47 +02:00
<div class="field">
<fieldset class="event type">
<legend>{{ctx.Locale.Tr "repo.settings.event_desc"}}</legend>
<label>
<input name="events" type="radio" value="push_only" {{if or $isNew .Webhook.PushOnly}}checked{{end}}>
{{ctx.Locale.Tr "repo.settings.event_push_only"}}
</label>
<label>
<input name="events" type="radio" value="send_everything" {{if .Webhook.SendEverything}}checked{{end}}>
{{ctx.Locale.Tr "repo.settings.event_send_everything"}}
</label>
<label>
<input name="events" type="radio" value="choose_events" {{if .Webhook.ChooseEvents}}checked{{end}}>
{{ctx.Locale.Tr "repo.settings.event_choose"}}
</label>
<fieldset class="hide-unless-checked">
<!-- Repository Events -->
<fieldset class="simple-grid grid-2">
<legend>{{ctx.Locale.Tr "repo.settings.event_header_repository"}}</legend>
<!-- Create -->
<label>
<input name="create" type="checkbox" {{if .Webhook.Create}}checked{{end}}>
{{ctx.Locale.Tr "repo.settings.event_create"}}
<span class="help">{{ctx.Locale.Tr "repo.settings.event_create_desc"}}</span>
</label>
<!-- Delete -->
<label>
<input name="delete" type="checkbox" {{if .Webhook.Delete}}checked{{end}}>
{{ctx.Locale.Tr "repo.settings.event_delete"}}
<span class="help">{{ctx.Locale.Tr "repo.settings.event_delete_desc"}}</span>
</label>
<!-- Fork -->
<label>
<input name="fork" type="checkbox" {{if .Webhook.Fork}}checked{{end}}>
{{ctx.Locale.Tr "repo.settings.event_fork"}}
<span class="help">{{ctx.Locale.Tr "repo.settings.event_fork_desc"}}</span>
</label>
<!-- Push -->
<label>
<input name="push" type="checkbox" {{if .Webhook.Push}}checked{{end}}>
{{ctx.Locale.Tr "repo.settings.event_push"}}
<span class="help">{{ctx.Locale.Tr "repo.settings.event_push_desc"}}</span>
</label>
<!-- Repository -->
<label>
<input name="repository" type="checkbox" {{if .Webhook.Repository}}checked{{end}}>
{{ctx.Locale.Tr "repo.settings.event_repository"}}
<span class="help">{{ctx.Locale.Tr "repo.settings.event_repository_desc"}}</span>
</label>
<!-- Release -->
<label>
<input name="release" type="checkbox" {{if .Webhook.Release}}checked{{end}}>
{{ctx.Locale.Tr "repo.settings.event_release"}}
<span class="help">{{ctx.Locale.Tr "repo.settings.event_release_desc"}}</span>
</label>
<!-- Package -->
<label>
<input name="package" type="checkbox" {{if .Webhook.Package}}checked{{end}}>
{{ctx.Locale.Tr "repo.settings.event_package"}}
<span class="help">{{ctx.Locale.Tr "repo.settings.event_package_desc"}}</span>
</label>
<!-- Wiki -->
<label>
<input name="wiki" type="checkbox" {{if .Webhook.Wiki}}checked{{end}}>
{{ctx.Locale.Tr "repo.settings.event_wiki"}}
<span class="help">{{ctx.Locale.Tr "repo.settings.event_wiki_desc"}}</span>
</label>
</fieldset>
<!-- Issue Events -->
<fieldset class="simple-grid grid-2">
<legend>{{ctx.Locale.Tr "repo.settings.event_header_issue"}}</legend>
<!-- Issues -->
<label>
<input name="issues" type="checkbox" {{if .Webhook.Issues}}checked{{end}}>
{{ctx.Locale.Tr "repo.settings.event_issues"}}
<span class="help">{{ctx.Locale.Tr "repo.settings.event_issues_desc"}}</span>
</label>
<!-- Issue Assign -->
<label>
<input name="issue_assign" type="checkbox" {{if .Webhook.IssueAssign}}checked{{end}}>
{{ctx.Locale.Tr "repo.settings.event_issue_assign"}}
<span class="help">{{ctx.Locale.Tr "repo.settings.event_issue_assign_desc"}}</span>
</label>
<!-- Issue Label -->
<label>
<input name="issue_label" type="checkbox" {{if .Webhook.IssueLabel}}checked{{end}}>
{{ctx.Locale.Tr "repo.settings.event_issue_label"}}
<span class="help">{{ctx.Locale.Tr "repo.settings.event_issue_label_desc"}}</span>
</label>
<!-- Issue Milestone -->
<label>
<input name="issue_milestone" type="checkbox" {{if .Webhook.IssueMilestone}}checked{{end}}>
{{ctx.Locale.Tr "repo.settings.event_issue_milestone"}}
<span class="help">{{ctx.Locale.Tr "repo.settings.event_issue_milestone_desc"}}</span>
</label>
<!-- Issue Comment -->
<label>
<input name="issue_comment" type="checkbox" {{if .Webhook.IssueComment}}checked{{end}}>
{{ctx.Locale.Tr "repo.settings.event_issue_comment"}}
<span class="help">{{ctx.Locale.Tr "repo.settings.event_issue_comment_desc"}}</span>
</label>
</fieldset>
<!-- Pull Request Events -->
<fieldset class="simple-grid grid-2">
<legend>{{ctx.Locale.Tr "repo.settings.event_header_pull_request"}}</legend>
<!-- Pull Request -->
<label>
<input name="pull_request" type="checkbox" {{if .Webhook.PullRequest}}checked{{end}}>
{{ctx.Locale.Tr "repo.settings.event_pull_request"}}
<span class="help">{{ctx.Locale.Tr "repo.settings.event_pull_request_desc"}}</span>
</label>
<!-- Pull Request Assign -->
<label>
<input name="pull_request_assign" type="checkbox" {{if .Webhook.PullRequestAssign}}checked{{end}}>
{{ctx.Locale.Tr "repo.settings.event_pull_request_assign"}}
<span class="help">{{ctx.Locale.Tr "repo.settings.event_pull_request_assign_desc"}}</span>
</label>
<!-- Pull Request Label -->
<label>
<input name="pull_request_label" type="checkbox" {{if .Webhook.PullRequestLabel}}checked{{end}}>
{{ctx.Locale.Tr "repo.settings.event_pull_request_label"}}
<span class="help">{{ctx.Locale.Tr "repo.settings.event_pull_request_label_desc"}}</span>
</label>
<!-- Pull Request Milestone -->
<label>
<input name="pull_request_milestone" type="checkbox" {{if .Webhook.PullRequestMilestone}}checked{{end}}>
{{ctx.Locale.Tr "repo.settings.event_pull_request_milestone"}}
<span class="help">{{ctx.Locale.Tr "repo.settings.event_pull_request_milestone_desc"}}</span>
</label>
<!-- Pull Request Comment -->
<label>
<input name="pull_request_comment" type="checkbox" {{if .Webhook.PullRequestComment}}checked{{end}}>
{{ctx.Locale.Tr "repo.settings.event_pull_request_comment"}}
<span class="help">{{ctx.Locale.Tr "repo.settings.event_pull_request_comment_desc"}}</span>
</label>
<!-- Pull Request Review -->
<label>
<input name="pull_request_review" type="checkbox" {{if .Webhook.PullRequestReview}}checked{{end}}>
{{ctx.Locale.Tr "repo.settings.event_pull_request_review"}}
<span class="help">{{ctx.Locale.Tr "repo.settings.event_pull_request_review_desc"}}</span>
</label>
<!-- Pull Request Sync -->
<label>
<input name="pull_request_sync" type="checkbox" {{if .Webhook.PullRequestSync}}checked{{end}}>
{{ctx.Locale.Tr "repo.settings.event_pull_request_sync"}}
<span class="help">{{ctx.Locale.Tr "repo.settings.event_pull_request_sync_desc"}}</span>
</label>
<!-- Pull Request Review Request -->
<label>
<input name="pull_request_review_request" type="checkbox" {{if .Webhook.PullRequestReviewRequest}}checked{{end}}>
{{ctx.Locale.Tr "repo.settings.event_pull_request_review_request"}}
<span class="help">{{ctx.Locale.Tr "repo.settings.event_pull_request_review_request_desc"}}</span>
</label>
</fieldset>
</fieldset>
</fieldset>
2014-08-24 14:59:47 +02:00
</div>
2015-08-28 17:36:13 +02:00
<!-- Branch filter -->
<div class="field">
<label for="branch_filter">{{ctx.Locale.Tr "repo.settings.branch_filter"}}</label>
<input id="branch_filter" name="branch_filter" type="text" value="{{or .Webhook.BranchFilter "*"}}">
<span class="help">{{ctx.Locale.Tr "repo.settings.branch_filter_desc" "https://pkg.go.dev/github.com/gobwas/glob#Compile" "github.com/gobwas/glob"}}</span>
</div>
{{$skipAuthorizationHeader := or (eq .HookType "sourcehut_builds") (eq .HookType "matrix")}}
{{if not $skipAuthorizationHeader}}
<!-- Authorization Header -->
<div class="field {{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}}">
<span class="help">{{ctx.Locale.Tr "repo.settings.authorization_header_desc" ("<code>Bearer token123456</code>, <code>Basic YWxhZGRpbjpvcGVuc2VzYW1l</code>" | SafeHTML)}}</span>
</div>
{{end}}
Add Webhook authorization header (#20926) _This is a different approach to #20267, I took the liberty of adapting some parts, see below_ ## Context In some cases, a weebhook endpoint requires some kind of authentication. The usual way is by sending a static `Authorization` header, with a given token. For instance: - Matrix expects a `Bearer <token>` (already implemented, by storing the header cleartext in the metadata - which is buggy on retry #19872) - TeamCity #18667 - Gitea instances #20267 - SourceHut https://man.sr.ht/graphql.md#authentication-strategies (this is my actual personal need :) ## Proposed solution Add a dedicated encrypt column to the webhook table (instead of storing it as meta as proposed in #20267), so that it gets available for all present and future hook types (especially the custom ones #19307). This would also solve the buggy matrix retry #19872. As a first step, I would recommend focusing on the backend logic and improve the frontend at a later stage. For now the UI is a simple `Authorization` field (which could be later customized with `Bearer` and `Basic` switches): ![2022-08-23-142911](https://user-images.githubusercontent.com/3864879/186162483-5b721504-eef5-4932-812e-eb96a68494cc.png) The header name is hard-coded, since I couldn't fine any usecase justifying otherwise. ## Questions - What do you think of this approach? @justusbunsi @Gusted @silverwind - ~~How are the migrations generated? Do I have to manually create a new file, or is there a command for that?~~ - ~~I started adding it to the API: should I complete it or should I drop it? (I don't know how much the API is actually used)~~ ## Done as well: - add a migration for the existing matrix webhooks and remove the `Authorization` logic there _Closes #19872_ Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: Gusted <williamzijl7@hotmail.com> Co-authored-by: delvh <dev.lh@web.de>
2022-11-03 19:23:20 +01:00
<div class="divider"></div>
2015-08-28 17:36:13 +02:00
<fieldset>
<label>
<input name="active" type="checkbox" {{if or $isNew .Webhook.IsActive}}checked{{end}}>
{{ctx.Locale.Tr "repo.settings.active"}}
<span class="help">{{ctx.Locale.Tr "repo.settings.active_helper"}}</span>
</label>
{{if $isNew}}
<button class="ui primary button">{{ctx.Locale.Tr "repo.settings.add_webhook"}}</button>
{{else}}
<button class="ui primary button">{{ctx.Locale.Tr "repo.settings.update_webhook"}}</button>
<a class="ui red delete-button button" data-url="{{.BaseLink}}/delete" data-id="{{.Webhook.ID}}">{{ctx.Locale.Tr "repo.settings.delete_webhook"}}</a>
{{end}}
</fieldset>
2015-08-26 18:30:06 +02:00
{{template "repo/settings/webhook/delete_modal" .}}