-
Notifications
You must be signed in to change notification settings - Fork 32
🎨 webserver: cache authenticated calls #7826
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
Conversation
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.
Pull Request Overview
This PR improves authentication performance and reliability by reducing database requests via caching and migrating to the asyncpg engine for asynchronous database access. Key changes include:
- Replacing the legacy db engine with the new asyncpg engine in authentication functions.
- Increasing the caching time-to-live for burst requests from 5 seconds to 30 minutes.
- Adjusting database connection contexts and query methods to work with the AsyncEngine.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| services/web/server/src/simcore_service_webserver/security/_authz_policy.py | Updated to use asyncpg engine and increased cache TTL for authenticated calls. |
| services/web/server/src/simcore_service_webserver/security/_authz_db.py | Migrated async database calls from aiopg to SQLAlchemy's AsyncEngine and adjusted query methods accordingly. |
Comments suppressed due to low confidence (2)
services/web/server/src/simcore_service_webserver/security/_authz_policy.py:31
- The cache TTL has been increased significantly from 5 seconds to 30 minutes. Please ensure that this duration aligns with the intended balance between performance improvements and authentication freshness.
_AUTHZ_BURST_CACHE_TTL: Final = (30 * _MINUTE)
services/web/server/src/simcore_service_webserver/security/_authz_policy.py:126
- [nitpick] The debug log for invalid identity or permission has been removed. Consider documenting the rationale for the omission or adding an alternative diagnostic mechanism, if deemed necessary, to aid future troubleshooting.
if identity is None or permission is None:
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7826 +/- ##
==========================================
- Coverage 86.72% 79.34% -7.38%
==========================================
Files 1851 703 -1148
Lines 71967 33582 -38385
Branches 1218 176 -1042
==========================================
- Hits 62410 26646 -35764
+ Misses 9216 6878 -2338
+ Partials 341 58 -283
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
services/web/server/src/simcore_service_webserver/security/_authz_policy.py
Outdated
Show resolved
Hide resolved
mrnicegyu11
left a comment
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.
very nice, as you already said I can confirm this is not a security issue at all :)
GitHK
left a comment
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.
thanks
giancarloromeo
left a comment
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.
👌
e04eb7f to
1da293b
Compare
1da293b to
e43803d
Compare
sanderegg
left a comment
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.
very nice! thanks a lot
how many connections does the asyncpg engine create?
e43803d to
87419e6
Compare
|



What do these changes do?
asyncpgRelated issue/s
How to test
w/o cache), we can directly observe the impact of database access on performance.asyncpg, which raises concerns. This may suggest that there are still inefficiencies in the way we are using the library or misconfigurations in how we're using the new engine!!Dev-ops