Expand description
PDK Token Introspection Library
Library which provides token introspection functionality for OAuth2 and OpenID Connect token validation policies.
§Primary types
TokenValidatorBuilder: Builder for creating TokenValidator instancesTokenValidator: Validator which handles cache, HTTP call, parsing and validationIntrospectionResult: Result of a successful token introspectionScopesValidator: Validates token scopes
§Example
ⓘ
use pdk::token_introspection::{TokenValidatorBuilder, ScopesValidator};
use pdk::hl::Service;
#[entrypoint]
async fn configure(
launcher: Launcher,
validator_builder: TokenValidatorBuilder, // Injected from context
Configuration(config): Configuration,
) -> Result<(), LaunchError> {
let service = Service::new(&config.host, config.port);
let scopes = ScopesValidator::all(vec!["read".into()]);
let validator = validator_builder
.new("token-validator")
.with_path("/introspect")
.with_authorization_value("Basic abc123")
.with_service(service)
.with_scopes_validator(scopes)
.build()?;
launcher.launch(on_request(|req| async {
let token = extract_token(&req)?;
let result = validator.validate(&token).await?;
println!("Client ID: {:?}", result.client_id());
})).await
}Structs§
- Expirable
Token - Token with expiration time that can be cached.
- Introspection
Result - Result of a successful token introspection.
- OneTime
UseToken - Token without expiration time (always considered expired).
- Scopes
Validator - Validates token scopes against required scopes.
- Token
Validator - Token validator that handles the complete validation flow including caching.
- Token
Validator Builder - Builder for creating TokenValidator instances.
- Token
Validator Builder Instance - A configurable instance of a token validator builder.
- Token
Validator Config - Configuration for the token validator.
Enums§
- Config
Error - Policy configuration errors.
- Introspection
Error - Errors from the introspection flow.
- Parsed
Token - Represents a parsed token from the introspection response.
- Token
Validator Build Error - Errors that can occur during token validator building.
- Validation
Error - Errors related to token validation.
- Value
- Represents any valid JSON value.
Traits§
- Token
- Common interface for parsed tokens.
Type Aliases§
- Object
- Type alias for token properties object