webauthn4j is a free, open source identity & access management (iam) project written in Java and released under Apache-2.0. It has 593 GitHub stars, 99 forks and 16 open issues, and was last pushed 22 days ago. On this registry it ranks #42 of 42 tracked projects in Identity & Access Management (IAM), with 5 head-to-head comparisons available.

What is webauthn4j?

WebAuthn4J is a portable, Apache-2.0 licensed Java library that performs server-side verification of WebAuthn and passkey ceremonies, aimed at Java and Kotlin teams that need to add FIDO2 relying-party support to an existing application or identity platform.

What it is

WebAuthn4J lives in the JVM ecosystem and implements the relying-party half of WebAuthn and FIDO2: the server side that receives the attestation and assertion responses produced by a browser and an authenticator, validates them, and decides whether a registration or an authentication should succeed. It is distributed on Maven Central as com.webauthn4j:webauthn4j-core, requires Java 17 or later, and builds with Gradle. The README states that all attestation statement formats are supported, and that the project passes all mandatory test cases and the optional Android Key attestation test cases of the FIDO2 Test Tools provided by the FIDO Alliance.

The concrete problem it replaces is the hand-written verification code that would otherwise sit inside an application: parsing CBOR and COSE structures, checking the challenge, origin and relying-party identifier, validating attestation statements and signatures, and retaining backward compatibility with the older FIDO U2F protocol. Rather than reading the WebAuthn specification and implementing those checks, a Java service adds one dependency and delegates verification to it. Because it is a verification library rather than a server, the surrounding user store, session handling and enrolment flow remain the application's responsibility.

Key capabilities

  • Server-side verification of WebAuthn and passkey registration and authentication ceremonies, published as com.webauthn4j:webauthn4j-core on Maven Central.
  • Support for every attestation statement format named in the README: packed, FIDO U2F, Android Key, Android SafetyNet, TPM, Apple Anonymous, Apple App Attest and none attestation.
  • Conformance with the FIDO2 Test Tools provided by the FIDO Alliance, including all mandatory test cases and the optional Android Key attestation cases.
  • A Kotlin-friendly public API: members carry NotNull or Nullable annotations so nullability is explicit to callers even though the library is written in Java.
  • Java 17 or later as the runtime prerequisite, with a Gradle-based build invoked through ./gradlew build.
  • Reproducible release artifacts, rebuildable from a tagged source checkout with the documented JDK toolchain and verifiable bit-for-bit against Maven Central by SHA-256 comparison.
  • A companion extension, WebAuthn4J Spring Security, maintained by the WebAuthn4J project to add WebAuthn and passkey support to Spring Security.

Who uses it and how

  • Keycloak and the Red Hat build of Keycloak use it as the verification layer behind passkey authentication in an identity provider.
  • Spring Security ships passkeys support in its spring-security-web module, maintained by the Spring Security project, with WebAuthn4J Spring Security available as an additional extension.
  • Quarkus Security covers WebAuthn in its own security guidance, embedding the library in a framework-level authentication stack.
  • Eclipse Vert.x Auth incorporates it in the vertx-auth family, and OpenAM from OpenIdentityPlatform and OpenUnison also list it among their dependencies.
  • Adoption therefore tends to come from platform and identity engineering teams that are extending an existing Java authentication stack rather than assembling a standalone product.

Getting started

Add the com.webauthn4j:webauthn4j-core dependency from Maven Central, currently at version 0.31.10.RELEASE, to a Java 17 or later project. Building from source is done with ./gradlew build after cloning https://github.com/webauthn4j/webauthn4j, and fuller detail is available in the reference documentation at https://webauthn4j.github.io/webauthn4j/en/.

How it compares

No comparable Java WebAuthn verification libraries, and no paid products that it is stated to replace, are named in the facts for this entry, so WebAuthn4J stands alone in this registry as a server-side FIDO2 and WebAuthn verification library for the JVM. What the facts do show is its position in a wider stack: it is the component consumed by larger frameworks such as Keycloak, Spring Security, Quarkus Security and Eclipse Vert.x Auth rather than a competing end-user product.

When to use it — and when not to

Choose it when a Java or Kotlin service already owns its own user store and needs standards-compliant WebAuthn verification without writing the cryptographic and protocol validation itself. Do not choose it as a turnkey identity product: it bundles no server, no database, no administrative console and no hosting, so the operator supplies persistence, session management and the enrolment user interface. The README is also concise by design and defers to the external reference site, so a team unwilling to read that documentation will find the repository alone thin.

project readme (upstream, from github) — read inline

WebAuthn4J

WebAuthn4J

Actions Status Coverage Build Status Reproducible Builds license

A portable Java library for WebAuthn(Passkeys) server side verification

Conformance

All mandatory test cases and optional Android Key attestation test cases of FIDO2 Test Tools provided by FIDO Alliance are passed.

Supported Attestation statement format

All attestation statement formats are supported.

  • Packed attestation
  • FIDO U2F attestation
  • Android Key attestation
  • Android SafetyNet attestation
  • TPM attestation
  • Apple Anonymous attestation
  • None attestation
  • Apple App Attest attestation

Kotlin friendly

Although WebAuthn4J is written in Java, public members are marked by NotNull or Nullable annotation to declare nullability explicitly.

Projects using WebAuthn4J

Documentation

You can find out more details from the reference.

Getting from Maven Central

If you are using Maven, just add the webauthn4j as a dependency:

<properties>
  ...
  <!-- Use the latest version whenever possible. -->
  <webauthn4j.version>0.31.10.RELEASE</webauthn4j.version>
  ...
</properties>

<dependencies>
  ...
  <dependency>
    <groupId>com.webauthn4j</groupId>
    <artifactId>webauthn4j-core</artifactId>
    <version>${webauthn4j.version}</version>
  </dependency>
  ...
</dependencies>

Build from source

WebAuthn4J uses a Gradle based build system. In the instructions below, gradlew is invoked from the root of the source tree and serves as a cross-platform, self-contained bootstrap mechanism for the build.

Prerequisites

Java17 or later is required to use WebAuthn4J.

Checkout sources

git clone https://github.com/webauthn4j/webauthn4j

Build all jars

./gradlew build

Reproducible builds

WebAuthn4J is committed to software supply chain security. All release artifacts support reproducible builds — you can rebuild from source and verify that the result is bit-for-bit identical to the artifacts published on Maven Central.

The exact JDK version used for each release is listed in the release notes.

git clone https://github.com/webauthn4j/webauthn4j.git
cd webauthn4j
git checkout <VERSION>.RELEASE
./gradlew jar -PtoolchainJdkVersion=<JDK_VERSION>

Then compare the locally built JARs against Maven Central:

VERSION=<VERSION>.RELEASE
find . -path "*/build/libs/webauthn4j-*-${VERSION}.jar" | while read jar; do
  module=$(basename "$jar" "-${VERSION}.jar")
  local=$(sha256sum "$jar" | cut -d' ' -f1)
  central=$(curl -sL "https://repo1.maven.org/maven2/com/webauthn4j/${module}/${VERSION}/${module}-${VERSION}.jar" \
    | sha256sum | cut -d' ' -f1)
  echo "$module: $([ "$local" = "$central" ] && echo MATCH || echo MISMATCH)"
done

All modules should show MATCH.

How to use

Parse and Validation on WebAuthn registration

If your would like to verify Apple App Attest, please see the reference.

String registrationResponseJSON = "<registrationResponseJSON>"; /* set registrationResponseJSON received from frontend */
RegistrationData registrationData;
try {
    registrationData = webAuthnManager.parseRegistrationResponseJSON(registrationResponseJSON);
} catch (DataConversionException e) {
    // If you would like to handle WebAuthn data structure parse error, please catch DataConversionException
    throw e;
}

// Server properties
Origin origin = null /* set origin */;
String rpId = null /* set rpId */;
Challenge challenge = null /* set challenge */;
byte[] tokenBindingId = null /* set tokenBindingId */;
ServerProperty serverProperty = new ServerProperty(origin, rpId, challenge, tokenBindingId);

// expectations
List<PublicKeyCredentialParameters> pubKeyCredParams = null;
boolean userVerificationRequired = false;
boolean userPresenceRequired = true;

RegistrationParameters registrationParameters = new RegistrationParameters(serverProperty, pubKeyCredParams, userVerificationRequired, userPresenceRequired);
try {
    webAuthnManager.verify(registrationData, registrationParameters);
} catch (VerificationException e) {
    // If you would like to handle WebAuthn data verification error, please catch VerificationException
    throw e;
}

// please persist CredentialRecord object, which will be used in the authentication process.
CredentialRecord credentialRecord =
        new CredentialRecordImpl( // You may create your own CredentialRecord implementation to save friendly authenticator name
                registrationData.getAttestationObject(),
                registrationData.getCollectedClientData(),
                registrationData.getClientExtensions(),
                registrationData.getTransports()
        );
save(credentialRecord); // please persist credentialRecord in your manner

Parse and Validation on authentication

String authenticationResponseJSON = "<authenticationResponseJSON>"; /* set authenticationResponseJSON received from frontend */

AuthenticationData authenticationData;
try {
    authenticationData = webAuthnManager.parseAuthenticationResponseJSON(authenticationResponseJSON);
} catch (DataConversionException e) {
    // If you would like to handle WebAuthn data structure parse error, please catch DataConversionException
    throw e;
}

// Server properties
Origin origin = null /* set origin */;
String rpId = null /* set rpId */;
Challenge challenge = null /* set challenge */;
byte[] tokenBindingId = null /* set tokenBindingId */;
ServerProperty serverProperty = new ServerProperty(origin, rpId, challenge, tokenBindingId);

// expectations
List<byte[]> allowCredentials = null;
boolean userVerificationRequired = true;
boolean userPresenceRequired = true;

CredentialRecord credentialRecord = load(authenticationData.getCredentialId()); // please load authenticator object persisted in the registration process in your manner
AuthenticationParameters authenticationParameters =
        new AuthenticationParameters(
                serverProperty,
                credentialRecord,
                allowCredentials,
                userVerificationRequired,
                userPresenceRequired
        );

try {
    webAuthnManager.verify(authenticationData, authenticationParameters);
} catch (VerificationException e) {
    // If you would like to handle WebAuthn data validation error, please catch ValidationException
    throw e;
}
// please update the counter of the authenticator record
updateCounter(authenticationData.getCredentialId(), authenticationData.getAuthenticatorData().getSignCount());

Sample application

WebAuthn4J Spring Security is built on the top of WebAuthn4J, and its sample application demonstrates WebAuthn4J feature well. Please see WebAuthn4J Spring Security sample application.

License

WebAuthn4J is Open Source software released under the Apache 2.0 license.

Contributing

Interested in helping out with WebAuthn4J? Great! Your participation in the community is much appreciated! Please feel free to open issues and send pull-requests.

Frequently asked questions

Is webauthn4j free to use?

webauthn4j is open source under the Apache-2.0 licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does webauthn4j do?

A portable Java library for WebAuthn(Passkeys) server side verification

What is webauthn4j written in?

webauthn4j is primarily written in Java. Its source is publicly available at https://github.com/webauthn4j/webauthn4j, and it has 593 GitHub stars.