Skip to content

Commit

Permalink
satellite/console: Add rate limiting to api key handlers
Browse files Browse the repository at this point in the history
Rate limit API key creation and deletion functionality with the user ID
rate limiter.

Change-Id: Id731b27363aa99a7135ac6cd4c639f2fdd290323
  • Loading branch information
mobyvb authored and andriikotko committed May 9, 2024
1 parent 2b13d98 commit a4296c1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions satellite/console/consoleweb/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,10 +402,10 @@ func NewServer(logger *zap.Logger, config Config, service *console.Service, oidc
apiKeysRouter := router.PathPrefix("/api/v0/api-keys").Subrouter()
apiKeysRouter.Use(server.withCORS)
apiKeysRouter.Use(server.withAuth)
apiKeysRouter.HandleFunc("/create/{projectID}", apiKeysController.CreateAPIKey).Methods(http.MethodPost, http.MethodOptions)
apiKeysRouter.Handle("/create/{projectID}", server.userIDRateLimiter.Limit(http.HandlerFunc(apiKeysController.CreateAPIKey))).Methods(http.MethodPost, http.MethodOptions)
apiKeysRouter.Handle("/delete-by-name", server.userIDRateLimiter.Limit(http.HandlerFunc(apiKeysController.DeleteByNameAndProjectID))).Methods(http.MethodDelete, http.MethodOptions)
apiKeysRouter.Handle("/delete-by-ids", server.userIDRateLimiter.Limit(http.HandlerFunc(apiKeysController.DeleteByIDs))).Methods(http.MethodDelete, http.MethodOptions)
apiKeysRouter.HandleFunc("/list-paged", apiKeysController.GetProjectAPIKeys).Methods(http.MethodGet, http.MethodOptions)
apiKeysRouter.HandleFunc("/delete-by-name", apiKeysController.DeleteByNameAndProjectID).Methods(http.MethodDelete, http.MethodOptions)
apiKeysRouter.HandleFunc("/delete-by-ids", apiKeysController.DeleteByIDs).Methods(http.MethodDelete, http.MethodOptions)
apiKeysRouter.HandleFunc("/api-key-names", apiKeysController.GetAllAPIKeyNames).Methods(http.MethodGet, http.MethodOptions)

analyticsController := consoleapi.NewAnalytics(logger, service, server.analytics)
Expand Down

0 comments on commit a4296c1

Please sign in to comment.