Package org.jenkinsci.plugins
Class BearerTokenFilter
java.lang.Object
org.jenkinsci.plugins.BearerTokenFilter
- All Implemented Interfaces:
jakarta.servlet.Filter
Authenticates REST / API requests that present a Keycloak access token as
Authorization: Bearer <token>.
The token is verified against the realm using the same adapter deployment
the browser flow uses: signature (via the realm JWKS), issuer, expiry and —
when verify-token-audience is enabled in the adapter config — audience.
On success the request runs as the token's user for that request only; no HTTP
session is created. Any verification failure is logged and the request
continues unauthenticated (anonymous), letting Jenkins' normal authorization
decide the outcome.
The filter is inserted into the security filter chain (see
KeycloakSecurityRealm.createFilter(FilterConfig)) after session
integration and the anonymous filter, so the authentication it sets is visible
to Jenkins' permission checks.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
BearerTokenFilter
public BearerTokenFilter()
-
-
Method Details
-
init
public void init(jakarta.servlet.FilterConfig filterConfig) - Specified by:
initin interfacejakarta.servlet.Filter
-
destroy
public void destroy()- Specified by:
destroyin interfacejakarta.servlet.Filter
-
doFilter
public void doFilter(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, jakarta.servlet.FilterChain chain) throws IOException, jakarta.servlet.ServletException - Specified by:
doFilterin interfacejakarta.servlet.Filter- Throws:
IOExceptionjakarta.servlet.ServletException
-