shyjsarah opened a new pull request, #7564:
URL: https://github.com/apache/paimon/pull/7564
### Purpose
This PR implements user identity-based token cache isolation in
`RESTTokenFileIO` to prevent multiple users from sharing the same data token
when accessing the same table location.
**Problem**: The previous implementation used only table identifier as the
token cache key, causing token cache pollution when multiple users accessed the
same table within a single process. All users would share the same data token
regardless of their actual authentication credentials.
**Solution**:
- Use `(path, user_identity)` as the token cache key to ensure proper
isolation between different users
- Extract user identity from authentication provider (Bear Token, DLF
AccessKey, ECS Role, STS File, etc.)
- Implement double-check locking pattern for thread-safe token caching
- Path-based caching avoids issues with table renames (physical location
remains constant)
**Key Changes**:
1. Add `user_identity` parameter to `RESTTokenFileIO.__init__()` - stores
user identity for cache key construction
2. Add `_extract_user_identity()` method in `RESTCatalog` to extract user
identity from auth provider:
- Bear Token → `"bear:{token}"`
- DLF AccessKey → `"dlf:{access_key_id}"`
- ECS Role → `"ecs:{role_name}"`
- Other loaders → `"loader:{type}"`
3. Modify `try_to_refresh_token()` to use `(path, user_identity)` tuple as
cache key
4. Implement thread-safe token cache with double-check locking (instance
lock + global cache lock)
5. Pass `user_identity` when creating `RESTTokenFileIO` instances in
`file_io_for_data()`
### Tests
- `test_different_users_have_separate_token_cache` - Verifies different
users get separate tokens for same path
- `test_same_user_reuses_token_cache` - Verifies same user reuses cached
token
- `test_table_rename_preserves_token_cache` - Verifies table rename doesn't
break token cache (path-based)
- `test_empty_user_identity_isolation` - Verifies empty user identity
handling
- `test_token_cache_with_expiry_check` - Verifies token expiration checking
logic
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]