Skip to content

Commit

Permalink
Merge pull request #2852 from gobitfly/NOBIDS/do-not-ratelimit-apidocs
Browse files Browse the repository at this point in the history
(NOBIDS) do not ratelimit api-docs and internal api per default
  • Loading branch information
recy21 authored Mar 13, 2024
2 parents d745f50 + 597df05 commit ff7e000
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions cmd/misc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,15 @@ func disableUserPerEmail() error {
if opts.Email == "" {
return errors.New("no email specified")
}

if utils.Config.Frontend.SessionSecret == "" {
return fmt.Errorf("session secret is empty, please provide a secure random string")
}

logrus.Infof("initializing session store: %v", utils.Config.RedisSessionStoreEndpoint)

utils.InitSessionStore(utils.Config.Frontend.SessionSecret)

user := struct {
ID uint64 `db:"id"`
Email string `db:"email"`
Expand Down
2 changes: 1 addition & 1 deletion ratelimit/ratelimit.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func (r *responseWriterDelegator) Status() int {
}

var DefaultRequestFilter = func(req *http.Request) bool {
if req.URL == nil || !strings.HasPrefix(req.URL.Path, "/api") {
if req.URL == nil || !strings.HasPrefix(req.URL.Path, "/api") || strings.HasPrefix(req.URL.Path, "/api/i/") || strings.HasPrefix(req.URL.Path, "/api/v1/docs/") || strings.HasPrefix(req.URL.Path, "/api/v2/docs/") {
return false
}
return true
Expand Down

0 comments on commit ff7e000

Please sign in to comment.