You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gitea/modules/structs
oliverpool b6e81357bd
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>
2 years ago
..
activitypub.go User keypairs and HTTP signatures for ActivityPub federation using go-ap (#19133) 3 years ago
admin_user.go Respect DefaultUserIsRestricted system default when creating new user (#19310) 3 years ago
attachment.go Fix wrong hint when status checking is running on pull request view (#9886) 5 years ago
commit_status.go [Refactor] CombinedStatus and CommitStatus related functions & structs (#14026) 4 years ago
cron.go Add cron running API (#12421) 5 years ago
doc.go
fork.go - name: new parameter in CreateForkOption to give the forked repository (#18066) 3 years ago
git_blob.go
git_hook.go
hook.go Add Webhook authorization header (#20926) 2 years ago
issue.go Deal with markdown template without metadata (#21639) 2 years ago
issue_comment.go Add API to get issue/pull comments and events (timeline) (#17403) 3 years ago
issue_label.go [API] Fix inconsistent label color format (#10129) 5 years ago
issue_milestone.go Add Created & Updated to Milestone (#12662) 5 years ago
issue_reaction.go [API] Fix 9544 | return 200 when reaction already exist (#9550) 5 years ago
issue_stopwatch.go Display current stopwatch in navbar (#14122) 4 years ago
issue_tracked_time.go [API] Extend times API (#9200) 5 years ago
lfs_lock.go
mirror.go Add new API endpoints for push mirrors management (#19841) 3 years ago
miscellaneous.go API method to list all commits of a repository (#6408) 6 years ago
nodeinfo.go Add nodeinfo endpoint for federation purposes (#16953) 4 years ago
notifications.go API: add html urls to notification subjects (#17178) 4 years ago
org.go Add name field for org api (#21270) 3 years ago
org_member.go
org_team.go Fix typo in API comment document (#21347) 3 years ago
org_type.go Add more linters to improve code readability (#19989) 3 years ago
package.go Add Package Registry (#16510) 3 years ago
pull.go Add API endpoint to get changed files of a PR (#21177) 3 years ago
pull_review.go Dismiss prior pull reviews if done via web in review dismiss (#20197) 3 years ago
release.go Add single release page and latest redirect (#11102) 5 years ago
repo.go Make external issue tracker regexp configurable via API (#21338) 3 years ago
repo_branch.go Support unprotected file patterns (#16395) 4 years ago
repo_collaborator.go Add API to query collaborators permission for a repository (#18761) 3 years ago
repo_commit.go More commit info from API (#19252) 3 years ago
repo_file.go Add latest commit's SHA to content response (#20398) 3 years ago
repo_key.go
repo_note.go Add an api endpoint to fetch git notes (#15373) (#16649) 4 years ago
repo_refs.go
repo_tag.go [API] Add repoCreateTag (#16165) 4 years ago
repo_topic.go Add API endpoint for accessing repo topics (#7963) 6 years ago
repo_tree.go
repo_watch.go
repo_wiki.go Add API to get/edit wiki (#17278) 4 years ago
settings.go Add custom emoji support (#16004) 4 years ago
status.go [Refactor] CombinedStatus and CommitStatus related functions & structs (#14026) 4 years ago
task.go Move migrating repository from frontend to backend (#6200) 6 years ago
user.go Include login_name in adminCreateUser response (#20283) 3 years ago
user_app.go Record OAuth client type at registration (#21316) 2 years ago
user_email.go
user_gpgkey.go Add option to provide signature for a token to verify key ownership (#14054) 4 years ago
user_key.go