databendlabs / databend

๐——๐—ฎ๐˜๐—ฎ, ๐—”๐—ป๐—ฎ๐—น๐˜†๐˜๐—ถ๐—ฐ๐˜€ & ๐—”๐—œ. Modern alternative to Snowflake. Cost-effective and simple for massive-scale analytics. https://databend.com
https://docs.databend.com
Other
7.71k stars 732 forks source link

refactor: enhancements of HTTP client session. #16452

Closed youngsofun closed 1 week ago

youngsofun commented 1 week ago

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

  1. session auth by JWT not use session token. use header to pass client session id.
    1. . add need_refresh in session state, client do refresh only when it is true, client session id is written to meta only when there are temp tables (1. on /session/refresh 2. num of temp table changed from 0 to 1).
  2. add endpoint /auth/verify for gateway, instead of using select 1
  3. add need_sticky in session state, set to true if in txn or there are temp tables, server return error if it is true but server changed/restarted.
  4. rename renew -> refresh, to be consistent with term refresh_token and for JWT session, no token is newed
  5. extract HttpErrorCode to make it easier to return the right status code.
  6. adjust, extract and rename TTLs, add TTL_GRACE_PERIOD_QUERY, to cover latencies and time skews.
  7. check user or client_session_id of HTTPQuery to protect the query result.
  8. page handler no longer to get user from meta.

Tests

Type of change


This change isโ€‚Reviewable

what-the-diff[bot] commented 1 week ago

PR Summary