OIDC4J

OIDC4J - a Java library for building OAuth2 and OIDC servers

OIDC4J is a Java library for building OAuth2 and OpenID Connect providers inside your own web application. It provides protocol objects, state machines, discovery metadata, token issuance, introspection, revocation, userinfo support, and id_token signing.

It is not a standalone server. Your application owns HTTP routing, authentication, consent, persistence, and deployment.

Getting OIDC4J

<dependency>
    <groupId>com.elevenware.oidc4j</groupId>
    <artifactId>lib-oidc4j</artifactId>
    <version>0.1.5-SNAPSHOT</version>
</dependency>

Snapshots are available from Central’s snapshot repository:

<repository>
    <id>central-snapshots</id>
    <url>https://central.sonatype.com/repository/maven-snapshots</url>
</repository>

Building from source

./mvnw test
./mvnw package

Quick start

ProviderConfiguration config = ProviderConfiguration.builder()
        .issuer("https://auth.example.com")
        .clientAuthMethod("client_secret_basic")
        .grantType("authorization_code")
        .scope("openid")
        .scope("profile")
        .build();

SigningKeySource signingKeys = SigningKeySource.fromPemFile(
        Path.of("/etc/oidc4j/signing-key.pem"),
        "primary");

Provider provider = new Provider(
        config,
        new InMemoryClientStore(),
        new InMemoryPendingGrantStore(),
        new InMemoryIssuedGrantStore(),
        new InMemoryUserStore(),
        signingKeys);

Return provider.discoveryDocument() from /.well-known/openid-configuration and provider.getSigningKeyProvider().getPublicJwks().toJSONObject() from /jwks.

The repository includes a complete Javalin example in examples/javalin-v2.