-
Notifications
You must be signed in to change notification settings - Fork 1
fix: clean up expired OAuth codes to prevent memory leak #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,7 +30,18 @@ type codeEntry struct { | |
| } | ||
|
|
||
| func NewOAuthHandler(baseURL string, userRepo *user.Repository) *OAuthHandler { | ||
| return &OAuthHandler{baseURL: baseURL, userRepo: userRepo} | ||
| h := &OAuthHandler{baseURL: baseURL, userRepo: userRepo} | ||
| go func() { | ||
| for range time.Tick(5 * time.Minute) { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should ensure that |
||
| h.codes.Range(func(k, v any) bool { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. regarding that, I feel like if have the DoS vector attack that can leak huge cpu spike not sure if my current vpc could handle that 😅 we can keep that for now |
||
| if time.Now().After(v.(*codeEntry).expiresAt) { | ||
| h.codes.Delete(k) | ||
| } | ||
| return true | ||
| }) | ||
| } | ||
| }() | ||
| return h | ||
| } | ||
|
|
||
| // Metadata handles GET /.well-known/oauth-authorization-server | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this goroutine lacks an exit. in this current state there will be accumulation of goroutines if we have users multiple being login in