-
Notifications
You must be signed in to change notification settings - Fork 89
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
feat(backend): periodically clean up expired rows #388
Conversation
fb6922a
to
4c684b9
Compare
packages/auth/src/config/app.ts
Outdated
accessTokenExpirySeconds: envInt('ACCESS_TOKEN_EXPIRY_SECONDS', 10 * 60) // Default 10 minutes | ||
accessTokenExpirySeconds: envInt('ACCESS_TOKEN_EXPIRY_SECONDS', 10 * 60), // Default 10 minutes | ||
databaseCleanupWorkers: envInt('DATABASE_CLEANUP_WORKERS', 1), | ||
accessTokenMinDaysBeforeDeletion: 30 |
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.
Should this be configurable?
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.
I thought 10 minutes was reasonable but it's not actually part of the spec. I can just hardcode it if you think that's cleaner, though.
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.
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.
I second the above ☝️
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.
I could remove accessTokenMinDaysBeforeDeletion
and make expiresIn
non-nullable, but it seems like the spec recommends against removing expired tokens immediately:
Note that in many cases, the access token will have expired for regular use. To facilitate token rotation, the AS SHOULD honor the rotation request of the expired access token since it is likely that the client instance is attempting to refresh the expired token.
That makes me think that we'd still need to define a constant somewhere to prevent the auth service from cleaning up tokens before the client has a chance to request renewal of an expired token.
Maybe it doesn't need to be configurable, though. Let me know what you think
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.
Got it. Good point.
How about a configurable accessTokenDeletionDays
that processDatabaseCleanup
uses?
An access token would be deleted if (createdAt
+ expiresIn
+accessTokenDeletionDays
) < now
.
Should the old access token always be deleted (expired or otherwise) by token rotation?
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.
Co-authored-by: Brandon Wilson <brandon@coil.com>
Co-authored-by: Brandon Wilson <brandon@coil.com>
afceb40
to
4e48b7a
Compare
Co-authored-by: Brandon Wilson <brandon@coil.com>
Changes proposed in this pull request
auth
to periodically delete database rows that we consider "expired"accessTokens
tableContext
fixes #385Checklist
fixes #number