Skip to content

Commit

Permalink
fix: allow webhooks to be called from unauthenticated sources
Browse files Browse the repository at this point in the history
Signed-off-by: Donnie Adams <[email protected]>
  • Loading branch information
thedadams committed Nov 26, 2024
1 parent f532350 commit 82e7db2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/api/authz/authz.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var staticRules = map[string][]string{
// Allow access to the oauth2 endpoints
"/oauth2/",

"POST /api/webhooks/{id}",
"POST /api/webhooks/{namespace}/{id}",
"GET /api/token-request/{id}",
"POST /api/token-request",
"GET /api/token-request/{id}/{service}",
Expand Down
6 changes: 6 additions & 0 deletions pkg/api/handlers/webhooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,12 @@ func (a *WebhookHandler) List(req api.Context) error {
}

func (a *WebhookHandler) RemoveToken(req api.Context) error {
// There is a chance that an unauthorized user could sneak through our authorization because of the pattern matching we are using.
// Check that the user is an admin here.
if !req.UserIsAdmin() {
return types.NewErrHttp(http.StatusForbidden, "unauthorized")
}

var wh v1.Webhook
if err := req.Get(&wh, req.PathValue("id")); err != nil {
return err
Expand Down

0 comments on commit 82e7db2

Please sign in to comment.