feat: restrict certain endpoints from API tokens and/or read-only tokens

This commit is contained in:
Sam 2023-03-30 16:58:35 +02:00
parent 2716471fa9
commit ff75075b81
Signed by: sam
GPG key ID: B4EF20DDE721CAA1
13 changed files with 62 additions and 14 deletions

View file

@ -44,6 +44,10 @@ func (s *Server) ackWarning(w http.ResponseWriter, r *http.Request) (err error)
ctx := r.Context()
claims, _ := server.ClaimsFromContext(ctx)
if !claims.APIToken {
return server.APIError{Code: server.ErrMissingPermissions, Details: "This endpoint cannot be used by API tokens"}
}
id, err := strconv.ParseInt(chi.URLParam(r, "id"), 10, 64)
if err != nil {
return server.APIError{Code: server.ErrBadRequest}