Description
pac4j is an open-source security engine for Java applications, covering authentication and authorisation with OpenID Connect, SAML, CAS, OAuth, JWT and more. It is built so the same security model works across many web frameworks, including Spring Boot, Spring WebFlux, Jakarta EE, Play, Vert.x, Spark Java, Jooby, JAX-RS, Dropwizard, Javalin, Undertow, Ratpack and http4s. In a Spring Boot app, one configuration class sets up an OpenID Connect client and protects paths such as /protected/**, and the library creates the callback and logout endpoints for you. Moving to a CAS or SAML2 identity provider means changing the client class, while the rest of the code stays the same. Other mechanisms include LDAP, SQL, MongoDB, Kerberos and REST API authentication, along with roles, CORS, CSRF and HTTP security headers. pac4j is licensed under Apache 2.0, requires Java 17 or later, and has been open source since 2012. It is used by the CAS server, Apache Syncope and Apache Knox.…
Highlights
- OpenID Connect, SAML, CAS, OAuth and JWT
- One security model across Java frameworks
- Spring Boot setup in one configuration class
- Roles, CORS, CSRF and security headers
- Apache 2.0 licensed
Ratings & Reviews
No ratings yet
Be the first to rate pac4j.
People also visit
pac4j FAQ
What is pac4j?
A security engine for Java applications that handles authentication and authorisation.
Which sign-in protocols does it support?
OpenID Connect, SAML, CAS, OAuth, HTTP, LDAP, SQL, JWT, MongoDB, IP address, Kerberos and REST API, according to its list of mechanisms.
Which frameworks does it work with?
Spring Web MVC and Spring WebFlux, Jakarta EE, Play, Vert.x, Spark Java, Jooby, JAX-RS, Dropwizard, Javalin, Undertow, Ratpack, http4s and Shiro.
What Java version do I need?
Java 17 or later. The older release lines support Java 8 and 11.
How do I secure a Spring Boot app?
Extend Pac4jSecurityConfig, define a Config with a client such as OidcClient, and add the security interceptor to the paths you want protected.
Is it free?
Yes. It is Apache 2.0 licensed and has been open source since 2012. Commercial support is also offered.
What are the best pac4j alternatives?
Popular alternatives to pac4j include Keycloak, Oauth4webapi and Auth.js. See all pac4j alternatives



