pac4j: one Java security engine with per-protocol modules and per-framework integrations
Security engine for Java (authentication, authorization, multi frameworks): OpenID Connect, SAML2, CAS, OAuth, LDAP, JWT...
At a glance
- What is it?
- pac4j is a Java authentication and authorization library that puts OpenID Connect, SAML, CAS, OAuth, JWT, LDAP and more behind one set of concepts across many web frameworks. You assemble it from separately versioned modules, so the quick start is also a lesson in version bookkeeping.
- Who is it for?
- pac4j suits Java teams that need the same login and authorization model across several frameworks and several identity protocols, or that must delegate authentication to providers such as Keycloak, Entra ID or a CAS server. It is less convenient if you want a single dependency with one version number, because you pick modules and a framework integration that are versioned separately.
- Can I use it commercially?
- Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 1 day ago.
- What is it written in?
- Mainly Java, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 15, 2026, and from our analysis. They are not legal advice.
Star history
- pac4j/pac4j2,539 ★ · +20
| Repository | 2026-07-28 | 2026-11-15 |
|---|---|---|
| pac4j/pac4j | 2.5k | 2.5k |
20 Stars in the last 110 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
One set of concepts across a long list of frameworks
pac4j calls itself the security engine for Java: one API to add OpenID Connect, SAML, CAS, OAuth, JWT and LDAP authentication and authorization to any Java framework. The same concepts and configuration apply to Spring Boot, Jakarta EE, Play, Vert.x, Javalin and JAX-RS, among others. The README table also names Spring Web MVC, Spring Security, Spring WebFlux, Dropwizard, Spark Java, Undertow and Apache Shiro.
Support is not uniform. Jooby, http4s and Ratpack integrations are linked from outside the main repository, and Lagom and Akka HTTP are marked as archived. If your framework is one of the archived ones, you would be relying on an integration that is no longer developed, even though the core engine continues.
The quick start mixes two version numbers on purpose
The Spring Boot and OpenID Connect quick start adds two Maven dependencies, and their versions differ:
<dependency>
<groupId>org.pac4j</groupId>
<artifactId>spring-webmvc-pac4j</artifactId>
<version>8.0.3</version>
</dependency>
<dependency>
<groupId>org.pac4j</groupId>
<artifactId>pac4j-oidc</artifactId>
<version>6.5.9</version>
</dependency>The framework integration, spring-webmvc-pac4j, is at 8.0.3, while the protocol module, pac4j-oidc, is at 6.5.9. They are separate artifacts with their own release lines, so you cannot assume that matching numbers mean compatibility, nor that one number upgrades the other. The repository has no GitHub releases, so Maven Central, which the README badge links to for pac4j-core, is where current versions are listed.
The demo sets allowUnsignedIdTokens, which belongs nowhere near production
The quick start configuration builds an OidcConfiguration with a discovery URI on a demo CAS server, a client ID of myclient and a secret of mysecret, then creates a Config with a callback URL of http://localhost:8080/callback. One line carries a warning in a code comment: setAllowUnsignedIdTokens(true) is only for this demo server.
Accepting unsigned ID tokens removes a check that the identity provider's signature normally provides, so copying the sample unchanged into a real application would weaken the login. Remove that line when you point the client at a real provider. After the setup, every path under /protected requires an OpenID Connect login, and the user profile is available through the ProfileManager. Switching to Keycloak, Google or Microsoft Entra ID is described as a matter of changing the client.
Modules map to protocols, so you depend only on what you use
The repository is a multi-module build. Its directories include pac4j-core, pac4j-oidc, pac4j-saml, pac4j-cas, pac4j-oauth, pac4j-jwt, pac4j-ldap, pac4j-sql, pac4j-mongo, pac4j-kerberos, pac4j-http, pac4j-openid4vp, pac4j-config and pac4j-test, plus both pac4j-jakartaee and pac4j-javaee.
The README splits mechanisms into two groups. Login protocols are OpenID Connect, SAML, CAS, OAuth, HTTP, Kerberos and OpenID4VP. Credentials validation covers LDAP, SQL, JWT, MongoDB, IP address and a REST API. A pac4j-jwt dependency adds JWT handling, and you do not need to pull in SAML or LDAP to get it. The presence of both a jakartaee and a javaee module means you must choose the one that matches your servlet namespace.
Authorization, CSRF and security headers are part of the engine
Beyond login, pac4j includes authorization and web security: roles, authentication levels, CSRF protection, CORS and security headers. The authorization mechanisms are split between checks on the user profile, such as roles, and checks on the web request.
This breadth is convenient, because one configuration covers who the user is and what the request may do. It also means the engine sits in your request path, so a mistake in the protected URL pattern can leave an endpoint open. The quick start protects only paths under /protected, and anything outside that pattern is unprotected. After you wire the interceptor, request a protected and an unprotected path in a test, and confirm the first redirects to the login while the second does not.
Newer standards are covered by dedicated clients
pac4j lists support for OpenID for Verifiable Presentations, aimed at the EUDI wallet and eIDAS 2.0, and for OpenID Federation. OpenID4VP has its own pac4j-openid4vp module. These are listed under the future-ready heading, so they are newer additions and not the oldest part of the codebase.
On the other side, the project says it has been developed since 2013 and is embedded in Apereo CAS, Apache Syncope and Apache Knox, where it powers authentication delegation. That is a record of long use inside other projects, but it is the README's own statement. If you intend to rely on the newer wallet or federation clients, check their documentation pages for the exact scope before committing to them.
Releases live on Maven Central, and the last push was on 2026-10-31
The repository has no GitHub releases, so tagged downloads are absent from the releases page and versions are published as Maven artifacts. The most recent push was on 2026-10-31, and the license is Apache-2.0. The top level also holds a SECURITY.md, a CONTRIBUTING.md, a checkstyle configuration, a spotbugs exclusion file and a renovate.json for dependency updates.
Because a security library is exactly where an old version hurts, pin the module versions deliberately and check the project's security file and published advisories before choosing them. Build tooling is Maven, through the pom.xml at the root, so Gradle users add the same coordinates in their own format.
Editorial conclusion
pac4j suits Java teams that need the same login and authorization model across several frameworks and several identity protocols, or that must delegate authentication to providers such as Keycloak, Entra ID or a CAS server. It is less convenient if you want a single dependency with one version number, because you pick modules and a framework integration that are versioned separately. Check each module's current version on Maven Central before copying the quick start, and never copy the demo's unsigned token setting into production.
Frequently asked questions
what is pac4j
pac4j is a security engine for Java that offers one API for OpenID Connect, SAML, CAS, OAuth, JWT, LDAP and other authentication and authorization, across many Java frameworks.
what is pac4j used for
It adds login and authorization to Java web applications, with roles, CSRF protection, CORS and security headers. It is also embedded in Apereo CAS, Apache Syncope and Apache Knox.
what is pac4j jwt
pac4j-jwt is the module in the repository for JWT support, and JWT appears among the credentials validation mechanisms alongside LDAP, SQL, MongoDB, IP address and REST.
pac4j vs spring security
They are not mutually exclusive. The README has a separate guide for securing a Spring Security application with OpenID Connect through pac4j, as well as guides for Spring Web MVC and Spring WebFlux.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/pac4j-pac4j)Star history chart for your README
[](https://hysenlabs.com/projects/pac4j-pac4j)Was this useful?