Interface SmartAuthProvider
- All Known Implementing Classes:
FormLoginPkceProvider,StaticTokenProvider
Deliberately minimal and decoupled from fhir-frog-library's generic
ClientRequestInterceptor hook: this interface only knows how to *get* a token,
not how it gets attached to outgoing requests. asRequestInterceptor() is the
one bit of glue between the two, for the common case of "attach this token as a Bearer
header to every request."
Different targets need genuinely different strategies - a local test IdP with a
test-user bypass (FormLoginPkceProvider), a pre-obtained token
(StaticTokenProvider), and (not built here - see design.md's Non-Goals) a real
external IdP needing headless-browser automation, or a system-to-system target using
client-credentials. Implementations are swappable without touching this interface or
each other.
-
Method Summary
Modifier and TypeMethodDescriptiondefault ClientRequestInterceptorAdapt this provider into afhir-frog-libraryClientRequestInterceptorthat attachesobtainAccessToken()'s result as anAuthorization: Bearer <token>header on every outgoing request.Obtain an access token, running whatever flow this strategy implements.
-
Method Details
-
obtainAccessToken
String obtainAccessToken()Obtain an access token, running whatever flow this strategy implements.- Returns:
- the raw access token string (e.g. a JWT), suitable for use as
Authorization: Bearer <token> - Throws:
SmartAuthException- if the flow fails at any step
-
asRequestInterceptor
Adapt this provider into afhir-frog-libraryClientRequestInterceptorthat attachesobtainAccessToken()'s result as anAuthorization: Bearer <token>header on every outgoing request.Typical usage:
SmartAuthProvider auth = new FormLoginPkceProvider(...); TestScriptEngine engine = TestScriptEngine.builder() .serverUrl(baseUrl + "/fhir") .requestInterceptor(auth.asRequestInterceptor()) .build();Calls
obtainAccessToken()once per outgoing request; strategies that want to obtain the token once and reuse it (e.g. to avoid re-running a login flow for every request) should cache the result themselves.- Returns:
- a request interceptor attaching this provider's token as a Bearer header
-