Fork me on GitHub

REST API (v3.6)

pac4j allows you to validate users via a REST API.

1) Dependency

You need to use the following module: pac4j-http.

Example (Maven dependency):


2) RestAuthenticator

The RestAuthenticator validates the provided username/password by POSTing them as a basic authentication to an URL which must return:

In case of a successful authentication, a RestProfile is returned.

Example of a correct server response:

  "id": "1234",
  "attributes": {
    "firstName": "Jerome"

Example of a client:

RestAuthenticator authenticator = new RestAuthenticator("http://rest-api-url");
DirectBasicAuthClient directBasicAuthClient = new DirectBasicAuthClient(authenticator);