Skip to content
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

OAuth userinfo should be cached #21937

Open
oneonestar opened this issue May 11, 2024 · 0 comments
Open

OAuth userinfo should be cached #21937

oneonestar opened this issue May 11, 2024 · 0 comments

Comments

@oneonestar
Copy link
Member

oneonestar commented May 11, 2024

OAuth userinfo get from Idp should be cached. (userinfo from http-server.authentication.oauth2.userinfo-url)
Otherwise every time a user access WEB_UI API will trigger a HTTP call from coordinator to Idp to fetch userinfo.

Trino WebUI constantly fetch from /ui/api/stats, /ui/api/cluster, and /ui/api/query. Each API call will trigger a HTTP call to Idp in coordinator.

Benefits of adding a cache:

  • improve the performance for WebUI
  • lower the workload for coordinator

private Optional<JWTClaimsSet> queryUserInfo(String accessToken)
{
try {
UserInfoResponse response = httpClient.execute(new UserInfoRequest(userinfoUrl.get(), new BearerAccessToken(accessToken)), UserInfoResponse::parse);

Call stack:

queryUserInfo:400, NimbusOAuth2Client (io.trino.server.security.oauth2)
getJWTClaimsSet:392, NimbusOAuth2Client (io.trino.server.security.oauth2)
getClaims:184, NimbusOAuth2Client (io.trino.server.security.oauth2)
getAccessTokenClaims:142, OAuth2WebUiAuthenticationFilter (io.trino.server.ui)
2 hidden frames
filter:98, OAuth2WebUiAuthenticationFilter (io.trino.server.ui)
57 hidden frames

A naive cache implementation on queryUserInfo() shows significant improvement on latency.
Before:
image

After:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant