webhook: sourcehut_builds: ask for access_token instead of authorization_header

This commit is contained in:
oliverpool 2024-04-08 17:51:39 +02:00
parent 3155e21cbb
commit 36f05e6f4e
6 changed files with 37 additions and 24 deletions

View file

@ -361,6 +361,15 @@ func (w Webhook) HeaderAuthorization() (string, error) {
return secret.DecryptSecret(setting.SecretKey, w.HeaderAuthorizationEncrypted)
}
// HeaderAuthorizationTrimPrefix returns the decrypted Authorization with a specified prefix trimmed.
func (w Webhook) HeaderAuthorizationTrimPrefix(prefix string) (string, error) {
s, err := w.HeaderAuthorization()
if err != nil {
return "", err
}
return strings.TrimPrefix(s, prefix), nil
}
// SetHeaderAuthorization encrypts and sets the Authorization header.
func (w *Webhook) SetHeaderAuthorization(cleartext string) error {
if cleartext == "" {