Package org.apache.spark.security
Class FileTokenIngestor
Object
org.apache.spark.security.FileTokenIngestor
- All Implemented Interfaces:
TokenIngestor
A
TokenIngestor that reads an OIDC identity token from a file.
The file path is typically a Kubernetes projected service account token
(e.g., /var/run/secrets/tokens/spark-identity) or a path configured via
spark.security.oidc.identityToken.file.
This implementation:
- Detects file rotation via mtime change (only re-parses when the file changes)
- Parses JWT claims by Base64-decoding the payload segment directly, without signature verification, since the token is trusted from the local filesystem and works with both signed (RS256, ES256) and unsigned tokens
- Handles errors gracefully: malformed JWT, missing file, or empty content returns empty rather than throwing
- Since:
- 4.3.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionload()Attempt to load the current identity token and parse it into a UserContext.
-
Constructor Details
-
FileTokenIngestor
Construct a new FileTokenIngestor.- Parameters:
tokenPath- path to the identity token file (must not be null)
-
-
Method Details
-
load
Description copied from interface:TokenIngestorAttempt to load the current identity token and parse it into a UserContext.- Specified by:
loadin interfaceTokenIngestor- Returns:
- a present Optional containing the UserContext if a valid token is available, or empty if unavailable (e.g. empty content / missing file).
-