Use gitlab generic webhooks instead of drone-ci-service (#620)

Benefits:
- the webhook delivery history of the drone-ci-service is broken (no way to check if a webhook was successfully delivered by Gitlab)
- drone-ci-service has limited events support (for example no comment or branch deleted event)
- independent from drone integration in general
This commit is contained in:
Anbraten
2021-12-19 01:12:09 +01:00
committed by GitHub
parent ce462ce4ac
commit ed0a9fd756
5 changed files with 133 additions and 33 deletions

View File

@@ -52,10 +52,9 @@ func parse(raw string, fn SecretFunc) (*Token, error) {
}
func ParseRequest(r *http.Request, fn SecretFunc) (*Token, error) {
token := r.Header.Get("Authorization")
// first we attempt to get the token from the
// authorization header.
token := r.Header.Get("Authorization")
if len(token) != 0 {
log.Trace().Msgf("token.ParseRequest: found token in header: %s", token)
bearer := token
@@ -65,6 +64,11 @@ func ParseRequest(r *http.Request, fn SecretFunc) (*Token, error) {
return parse(bearer, fn)
}
token = r.Header.Get("X-Gitlab-Token")
if len(token) != 0 {
return parse(token, fn)
}
// then we attempt to get the token from the
// access_token url query parameter
token = r.FormValue("access_token")