Join our Newsletter — 33% off our NHI Course
Home› Guides› Quarkus Security Guide: OIDC, RBAC Annotations, Native Images…
Guide Application Security

Quarkus Security Guide: OIDC, RBAC Annotations, Native Images and Dev Services

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 19 November 2026 16 min read
On this page

Quarkus security comes down to a handful of configuration decisions: how OIDC tokens are verified, how HTTP permissions and annotations combine, and which development conveniences are kept out of production. Quarkus is a cloud-native Java framework built for containers and native executables, and its security model is assembled from extensions (OIDC, security annotations, HTTP permission policies) that are configured almost entirely in application.properties. That makes the configuration file the security boundary. A single property such as quarkus.oidc.token.issuer=any or a missing deny-by-default setting can quietly undo the controls a team believes it has.

This guide covers the Quarkus-specific settings that matter most for identity and access: bearer token and authorisation code flow configuration, role and permission mapping, the order in which path rules and annotations are checked, proactive authentication, Dev Services, native image considerations and the service credentials Quarkus applications hold. General Java hardening (deserialisation, dependency patching, keystores) is covered in our Java and Spring Security Guide and is not repeated here.

This is an independent guide from NHI Mgmt Group, based on the Quarkus project's public documentation as of November 2026. It is not sponsored or reviewed by the Quarkus project. Product features change, so confirm settings against the current Quarkus documentation.

Key takeaways

  • HTTP permission rules under quarkus.http.auth.permission are checked before standard security annotations, so @PermitAll cannot reopen a path that configuration has restricted.
  • Unannotated Jakarta REST endpoints are allowed by default. Set quarkus.security.jaxrs.deny-unannotated-endpoints=true or a default role so new endpoints fail closed.
  • Always set an expected issuer and audience for bearer tokens. The documentation describes quarkus.oidc.token.issuer=any as a last resort, and it should never reach production.
  • Know where roles come from. Quarkus reads groups, Keycloak realm and client roles, or a custom claim path, and a mismatch silently grants or denies access.
  • Dev Services for Keycloak create a realm with a known client secret and test users. Keep production connection settings in the %prod. profile so that convenience never leaks.
  • The OIDC client secret is the application's non-human identity. Prefer private_key_jwt or client_secret_jwt, which avoid sending the secret to the provider.

How the Quarkus security model fits together

Quarkus security has three layers that a reviewer needs to keep apart.

  • Authentication mechanisms establish a SecurityIdentity from the request: an OIDC bearer token, an authorisation code flow session, mutual TLS, basic or form authentication.
  • HTTP permission policies in configuration match request paths and methods to built-in policies (deny, permit, authenticated) or to named role policies.
  • Annotations on endpoints and CDI beans (@RolesAllowed, @PermitAll, @DenyAll, @Authenticated, @PermissionsAllowed) apply method-level checks.

The Quarkus authorisation reference states that authorisation checks for quarkus.http.auth. configurations run before checks for standard security annotations. In practice this means configuration is the outer gate and annotations are the inner gate. Both must allow a request. The documentation also recommends the Jakarta REST deny-by-default properties and annotations over HTTP path rules where possible, because annotations sit next to the code they protect and can override defaults per resource or method.

From an identity point of view, every Quarkus service usually holds at least one machine credential: an OIDC client ID and secret or private key for token introspection or code flow, plus whatever credentials it uses to call databases and downstream APIs. Treat these as managed non-human identities with owners, rotation and scoping, not as static configuration values.

Configuring OIDC bearer token verification

For a service that accepts access tokens from callers, the core settings are quarkus.oidc.auth-server-url and, where the service is API-only, quarkus.oidc.application-type=service. Quarkus discovers provider metadata by appending /.well-known/openid-configuration to the server URL. If discovery is disabled with quarkus.oidc.discovery-enabled=false, the token, JWKS, UserInfo and introspection paths must be set by hand, which is a common source of drift.

How Quarkus verifies tokens

  • JWT access tokens are verified against a key from the provider's JWKS endpoint, matched by the kid header. If no key matches, Quarkus refreshes the key set, limited by quarkus.oidc.token.forced-jwk-refresh-interval (10 minutes by default).
  • If no key matches after refresh, the token is sent to the introspection endpoint. Opaque tokens, including encrypted JWTs, are always introspected.
  • The exp claim is checked after the signature is verified.
  • quarkus.oidc.token.allow-jwt-introspection and quarkus.oidc.token.allow-opaque-token-introspection control fallbacks, and quarkus.oidc.token.require-jwt-introspection-only=true forces every JWT through introspection, which suits high-value APIs that need immediate revocation.

Issuer and audience

Set quarkus.oidc.token.issuer to the exact expected iss value and quarkus.oidc.token.audience to this service's identifier. Without an audience check, a token minted for any other application in the same realm can be replayed against this one. The documentation notes that setting the issuer to any skips issuer verification and should be used only when no other option works. If a Keycloak deployment produces issuer mismatches behind a proxy, fix the provider's frontend URL rather than relaxing the check. Our JWT Security Guide covers claim validation in more depth.

Client credentials for introspection

quarkus.oidc.client-id is required for remote introspection, which opaque tokens always need, and optional for local JWT-only verification. The documentation advises not to configure credentials when no remote endpoint is used. That is good practice in general: a service that only verifies signed JWTs locally should not hold a client secret at all.

Token caching

Introspection and UserInfo results can be cached, but quarkus.oidc.token-cache.max-size defaults to 0, so caching is off until a positive value is set. If you enable it, set time-to-live well below your revocation expectations. A cached introspection result keeps accepting a token the provider has already revoked.

Authorisation code flow for web applications

Applications that serve HTML and log users in through the provider use quarkus.oidc.application-type=web-app. Use hybrid when one application serves both pages and a REST API: the code flow starts only when no bearer token is present in the Authorization header.

  • PKCE. Enable it with quarkus.oidc.authentication.pkce-required=true. The code verifier is encrypted in the state cookie using quarkus.oidc.authentication.state-secret, a 32-character secret. Set it explicitly rather than relying on generation or fallback to the client secret.
  • State cookies. These last 5 minutes by default (quarkus.oidc.authentication.state-cookie-age) and get unique names per flow to support multiple tabs.
  • Session storage. By default the ID, access and refresh tokens are kept in an encrypted session cookie. quarkus.oidc.token-state-manager.strategy=id-refresh-tokens drops the access token if the application never uses it, which reduces what a stolen cookie yields. Database and Redis token state managers are available for server-side storage.
  • Cookie scope. quarkus.oidc.authentication.cookie-domain widens the session cookie to subdomains. Only set it when every subdomain is equally trusted.
  • Redirects. redirect-path fixes the callback path for providers that require one registered value, and restore-path-after-redirect=true returns the user to the original URL. Keep the provider's registered redirect URIs exact.
  • Error path. quarkus.oidc.authentication.error-path sets a custom provider error page. The documentation warns that this endpoint must be publicly accessible, or users loop back into authentication.
  • Logout. RP-initiated logout uses the provider's end-session endpoint (quarkus.oidc.end-session-path). Back-channel and front-channel logout are also supported, and should be tested so that a provider-side session kill actually ends the Quarkus session.

In code flow the ID token is always verified and is the default role source. The access token is verified only when injected as a JsonWebToken or when quarkus.oidc.roles.source=accesstoken. If you take roles from the access token, make sure it is being verified.

Client authentication to the provider

The documentation notes that client_secret_basic and client_secret_post send the client secret to the provider, while client_secret_jwt and private_key_jwt do not. Private key JWT is the strongest choice for production services because the private key never leaves the workload and can be held in a keystore or secrets manager.

Roles, permissions and annotation semantics

Where roles come from

Without explicit configuration, Quarkus OIDC reads roles from the groups claim, Keycloak realm_access/roles, or resource_access/<client-id>/roles. For opaque tokens, roles come from the introspection scope. quarkus.oidc.roles.role-claim-path points at a custom claim such as groups/roles, and quarkus.oidc.roles.source=userinfo takes roles from the UserInfo endpoint. Document the chosen source for each service. A provider change that renames a claim either locks everyone out or, worse, falls back to a broader default.

Roles can be remapped globally with quarkus.http.auth.roles-mapping.<role>=.... This is useful to translate provider group names into application roles, but every mapping is a place where a broad external group can become an admin role. Review mappings with the same care as group membership.

Annotations

  • @Authenticated is equivalent to @RolesAllowed("**"): any authenticated identity.
  • Method-level annotations take priority over class-level annotations. A class marked @RolesAllowed("admin") with a method marked @PermitAll exposes that method.
  • Annotations on an interface must be placed on the implementation class. Sub-resource locators declared as default interface methods cannot be secured with annotations at all.
  • @RolesAllowed accepts property expressions such as ${customer:User}, resolved at runtime. That keeps role names configurable but also means a configuration change can alter authorisation. Track it in change control.
  • @PermissionsAllowed requires at least one listed permission by default, and all of them with inclusive=true. With OIDC, permissions are mapped from the token's scope claim, which aligns well with machine-to-machine clients that hold scoped tokens rather than user roles.

Deny by default

Three properties turn Quarkus from fail-open to fail-closed:

PropertyDefaultEffect
quarkus.security.jaxrs.deny-unannotated-endpointsfalseTreats unannotated Jakarta REST endpoints as @DenyAll
quarkus.security.jaxrs.default-roles-allowedunsetApplies default roles to unannotated endpoints; ** means any authenticated user. Cannot be combined with the property above
quarkus.security.deny-unannotated-membersfalseDenies unannotated CDI methods in classes that have other annotated methods

Pick one of the first two for every service. The choice between them depends on whether most endpoints are internal (default roles) or mixed (deny unannotated and annotate explicitly).

HTTP permission policies and path matching

Path rules use quarkus.http.auth.permission.<name>.paths, .policy and optionally .methods. Role policies are defined with quarkus.http.auth.policy.<name>.roles-allowed. The matching rules are precise and worth learning:

  • A trailing * matches zero or more path segments, while a * in the middle matches exactly one segment. Other paths are exact matches.
  • Matching follows "longest path wins". When several permission sets match, the more specific method match takes precedence, and all winning permissions must allow the request.
  • Paths without a leading slash have quarkus.http.root-path prepended. Paths with a leading slash are used as written, so moving the root path can shift what a rule covers.
  • Policy paths must not contain a semicolon. Use a custom HttpSecurityPolicy if matrix parameters matter.
  • shared=true permissions apply to every matching request and are less efficient in large numbers.

The documentation itself warns that overlapping or complex path expressions are error-prone and recommends testing that allowed requests succeed and that missing credentials or insufficient roles are rejected. Treat a path permission change as a security change: add an automated test for every rule, including negative cases for adjacent paths.

Because path rules run first, a common safe pattern is a small set of configuration rules (deny everything under management or internal prefixes, permit health endpoints) combined with deny-unannotated endpoints and explicit annotations on business resources.

Proactive authentication

Quarkus authenticates every request that carries credentials by default, even when the target is public. Requests with invalid credentials are rejected, and requests without credentials proceed as anonymous. This is controlled by quarkus.http.auth.proactive.

Leaving proactive authentication on is the safer default. It means a stale or forged token is rejected at the edge of the application rather than reaching business code. Turning it off (quarkus.http.auth.proactive=false) defers authentication until something asks for the identity, which has side effects the documentation spells out:

  • Reading SecurityIdentity may block, which fails on the I/O thread of a reactive application. The reactive alternative is CurrentIdentityAssociation.getDeferredIdentity().
  • Standard security annotations on CDI beans with synchronous non-void methods can fail on the I/O thread with a BlockingOperationNotAllowedException.
  • Custom exception mappers for AuthenticationFailedException can break the challenge for mechanisms that build their own response, such as the code flow redirect. The documented safer option is to keep proactive authentication on and customise only the response through a route failure handler.

If a team disables proactive authentication to work around clients that send bad tokens to public endpoints, fix the clients instead and record the decision.

Dev Services, profiles and the path to production

Dev Services provision unconfigured services automatically in development and test mode, usually as containers. Dev Services for Keycloak create a quarkus realm with a quarkus-app client whose secret is secret, and users alice (roles admin and user) and bob (role user). That is ideal for local work and dangerous if any of it is copied into a shared environment.

  • The documentation states that Dev Services live in the deployment modules and do not affect the production application. The risk is not Dev Services running in production but their values being copied: realm exports, test users and the well-known client secret.
  • Configuring a service's connection disables its Dev Service automatically, and quarkus.devservices.enabled=false disables all of them. Use the second in shared CI environments that should only ever talk to real, controlled test infrastructure.
  • Put production connection and OIDC settings under the %prod. profile, as the documentation recommends, so dev and test keep using Dev Services and production never inherits them.
  • If you import a custom realm with quarkus.keycloak.devservices.realm-path, keep that file free of real users and real secrets.
  • Add a pipeline check that fails a production build if the OIDC client secret equals secret, if the issuer is any, or if the server URL points at a localhost or container address.

For hardening the Keycloak server itself, see our Keycloak Hardening Guide.

Native images, containers and service credentials

Quarkus applications are often compiled to native executables and shipped as small container images. Two security points follow.

First, native compilation is closed-world, so classes used reflectively must be registered. The authorisation reference notes that custom Permission classes used with native executables need @RegisterForReflection unless they also appear in a permission attribute of @PermissionsAllowed. A permission check that works in JVM mode but fails in the native build is a test gap, not a reason to loosen the check. Run your authorisation test suite against the native artefact, not only the JVM build.

Second, the credentials a Quarkus service holds are injected through configuration, which can come from environment variables, mounted files or configuration sources. Keep OIDC client secrets, private keys and database passwords out of application.properties in source control and out of container image layers. Where the platform supports it, use workload identity to fetch credentials at runtime. Our Container Image Security Guide covers image layer hygiene.

For outbound calls, prefer short-lived tokens obtained with the service's own client identity over long-lived API keys, and scope each client to the downstream audiences it actually calls. Keep a register of which Quarkus services hold which client IDs, who owns them, and when each secret or key was last rotated.

Testing and review

  • Write tests that call each protected endpoint with no token, an expired token, a token for a different audience and a token with insufficient roles, and assert 401 or 403 each time.
  • The documentation notes that testing with inlined public keys gives limited coverage because remote communication is not exercised. Include at least one test path against a real provider, such as a Dev Services Keycloak container in CI.
  • Review application.properties for every profile as part of code review. Configuration diffs are authorisation diffs in Quarkus.
  • Check that sender-constrained token options (DPoP via quarkus.oidc.token.authorization-scheme=dpop, or certificate binding via quarkus.oidc.token.binding.certificate=true) are tested end to end where they are used.

Common failure patterns

  • Fail-open endpoints. A new resource ships without annotations, and with deny-unannotated settings at their default it is reachable by anyone.
  • Expecting @PermitAll to override configuration. Teams add @PermitAll to a health or callback endpoint and cannot understand why a path rule still blocks it, then broaden the path rule instead of fixing it.
  • Issuer set to any. Added during a proxy debugging session and never removed, it lets tokens from other issuers through.
  • No audience check. Every token from the realm is accepted by every service.
  • Dev Services values in shared environments. The quarkus-app client with secret secret, or test users, end up in a staging realm import.
  • Role source drift. A provider change moves roles to a different claim and access silently changes.
  • Introspection cache longer than revocation tolerance. Revoked tokens keep working until the cache expires.
  • Client secrets in source. OIDC secrets committed in application.properties or baked into image layers.
  • JVM-only testing. Authorisation passes in JVM mode, but a native image behaves differently and nobody notices.

Practitioner checklist

  • Set quarkus.security.jaxrs.deny-unannotated-endpoints=true or default-roles-allowed on every service.
  • Set an explicit quarkus.oidc.token.issuer and quarkus.oidc.token.audience; block issuer=any in CI.
  • Document the role source (role-claim-path or roles.source) and review every roles-mapping entry.
  • Keep proactive authentication enabled unless there is a recorded reason.
  • Enable PKCE and set an explicit 32-character state-secret for web-app and hybrid applications.
  • Use private_key_jwt or client_secret_jwt for client authentication to the provider.
  • Keep production settings in %prod. and fail builds that contain Dev Services defaults.
  • Remove client credentials from services that only verify JWTs locally.
  • Test positive and negative authorisation cases for every path rule, in both JVM and native builds.
  • Register each service's OIDC client as a non-human identity with an owner and rotation date.

Standards and references

Related NHI Mgmt Group resources: Java and Spring Security Guide · Keycloak Hardening Guide · JWT Security Guide · OAuth 2.0 vs OIDC

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick both boxes to continue.