You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+26-26Lines changed: 26 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -79,7 +79,7 @@ public class SessionBackedChallengeNonceStore implements ChallengeNonceStore {
79
79
80
80
## 3. Configure the challenge nonce generator
81
81
82
-
The validation library needs to generate authentication challenge nonces and store them for later validation in the challenge nonce store. Overview of challenge nonce usage is provided in the [Web eID system architecture document](https://github.com/web-eid/web-eid-system-architecture-doc#authentication-1). The challenge nonce generator will be used in the REST endpoint that issues challenges; it is thread-safe and should be scoped as a singleton.
82
+
The validation library needs to generate authentication challenge nonces and store them for later validation in the challenge nonce store. Overview of challenge nonce usage is provided in the [Web eID system architecture document](https://github.com/web-eid/web-eid-system-architecture-doc#authentication-1). The challenge nonce generator will be used in the filter that issues challenges; it is thread-safe and should be scoped as a singleton.
83
83
84
84
Configure the challenge nonce generator as follows:
You must explicitly specify which **intermediate** certificate authorities (CAs) are trusted to issue the eID authentication and OCSP responder certificates. CA certificates can be loaded from either the truststore file, resources or any stream source. We use the [`CertificateLoader`](https://github.com/web-eid/web-eid-authtoken-validation-java/blob/main/src/main/java/eu/webeid/security/certificate/CertificateLoader.java) helper class to load CA certificates from resources here, but consider using [the truststore file](./blob/example/main/src/main/java/eu/webeid/example/config/ValidationConfiguration.java#L104-L123) instead.
102
+
You must explicitly specify which **intermediate** certificate authorities (CAs) are trusted to issue the eID authentication and OCSP responder certificates. CA certificates can be loaded from either the truststore file, resources or any stream source. We use the [`CertificateLoader`](src/main/java/eu/webeid/security/certificate/CertificateLoader.java) helper class to load CA certificates from resources here, but consider loading the truststore file (see [loadTrustedCACertificatesFromTrustStore](example/main/src/main/java/eu/webeid/example/config/ValidationConfiguration.java#L104-L123)) instead.
103
103
104
104
First, copy the trusted certificates, for example `ESTEID2018.cer`, to `resources/cacerts/`, then load the certificates as follows:
Both filters are registered in the Spring Security filter chain in ApplicationConfiguration
207
+
Both filters are registered in the Spring Security filter chain in ApplicationConfiguration.
208
208
See the full implementation [here](example/src/main/java/eu/webeid/example/config/ApplicationConfiguration.java):
209
209
```java
210
210
http
@@ -222,11 +222,11 @@ Authentication consists of calling the `validate()` method of the authentication
222
222
223
223
When using [Spring Security](https://spring.io/guides/topicals/spring-security-architecture) with standard cookie-based authentication,
224
224
225
-
- implement a custom authentication provider that uses the authentication token validator for authentication as shown [here](example/blob/main/src/main/java/eu/webeid/example/security/WebEidAuthenticationProvider.java),
226
-
- implement an AJAX authentication processing filter that extracts the authentication token and passes it to the authentication manager as shown [here](example/blob/main/src/main/java/eu/webeid/example/security/WebEidAjaxLoginProcessingFilter.java),
227
-
- configure the authentication provider and authentication processing filter in the application configuration as shown [here](example/blob/main/src/main/java/eu/webeid/example/config/ApplicationConfiguration.java).
225
+
- implement a custom authentication provider that uses the authentication token validator for authentication as shown [here](example/src/main/java/eu/webeid/example/security/WebEidAuthenticationProvider.java),
226
+
- implement an AJAX authentication processing filter that extracts the authentication token and passes it to the authentication manager as shown [here](example/src/main/java/eu/webeid/example/security/WebEidAjaxLoginProcessingFilter.java),
227
+
- configure the authentication provider and authentication processing filter in the application configuration as shown [here](example/src/main/java/eu/webeid/example/config/ApplicationConfiguration.java).
228
228
229
-
The gist of the validation is [in the `authenticate()` method](example/blob/main/src/main/java/eu/webeid/example/security/WebEidAuthenticationProvider.java#L74-L76) of the authentication provider:
229
+
The gist of the validation is [in the `authenticate()` method](example/src/main/java/eu/webeid/example/security/WebEidAuthenticationProvider.java#L74-L76) of the authentication provider:
The Web eID authentication token validation library for Java contains the implementation of the Web eID authentication token validation process in its entirety to ensure that the authentication token sent by the Web eID browser extension contains valid, consistent data that has not been modified by a third party. It also implements secure challenge nonce generation as required by the Web eID authentication protocol. It is easy to configure and integrate into your authentication service.
262
+
The Web eID authentication token validation library for Java contains the implementation of the Web eID authentication token validation process in its entirety to ensure that the authentication token sent by the Web eID browser extension or mobile application contains valid, consistent data that has not been modified by a third party. It also implements secure challenge nonce generation as required by the Web eID authentication protocol. It is easy to configure and integrate into your authentication service.
263
263
264
264
The authentication protocol, authentication token format, validation requirements and challenge nonce usage is described in more detail in the [Web eID system architecture document](https://github.com/web-eid/web-eid-system-architecture-doc#authentication-1).
265
265
@@ -358,10 +358,11 @@ The authentication token validation process consists of two stages:
358
358
359
359
- First, **user certificate validation**: the validator parses the token and extracts the user certificate from the *unverifiedCertificate* field. Then it checks the certificate expiration, purpose and policies. Next it checks that the certificate is signed by a trusted CA and checks the certificate status with OCSP.
360
360
- Second, **token signature validation**: the validator validates that the token signature was created using the provided user certificate by reconstructing the signed data `hash(origin)+hash(challenge)` and using the public key from the certificate to verify the signature in the `signature` field. If the signature verification succeeds, then the origin and challenge nonce have been implicitly and correctly verified without the need to implement any additional security checks.
361
-
- Additional validation for **Web eID authentication tokens (format v1.1)**:
362
-
- **Subject match check**: The subject of the signing certificate must match the subject of the authentication certificate.
363
-
This ensures both certificates belong to the same user.
364
-
- **Signing certificate validation**: Expiration, key usage, and policies are checked. The certificate must be signed by a trusted certificate authority. OCSP is used to verify the revocation status.
361
+
- Additional validation for **Web eID authentication tokens (format v1.1)**: the token must contain the `unverifiedSigningCertificates` field with at least one signing certificate entry. Each entry's `supportedSignatureAlgorithms` are validated against the set of allowed cryptographic algorithms, hash functions, and padding schemes. For each signing certificate, the following checks are performed:
362
+
-The subject must match the subject of the authentication certificate, ensuring both certificates belong to the same user.
363
+
-The issuing authority must match that of the authentication certificate, verified via the AuthorityKeyIdentifier (AKI) extension.
364
+
-The certificate must not be expired.
365
+
-The certificate must contain the non-repudiation key usage bit required for digital signatures.
365
366
366
367
The website back end must look up the challenge nonce from its local store using an identifier specific to the browser session, to guarantee that the authentication token was received from the same browser to which the corresponding challenge nonce was issued. The website back end must guarantee that the challenge nonce lifetime is limited and that its expiration is checked, and that it can be used only once by removing it from the store during validation.
367
368
@@ -449,7 +450,7 @@ The authentication protocol requires support for generating challenge nonces, la
449
450
450
451
The `-Djava.security.egd=file:/dev/./urandom` command line argument is added to `pom.xml` to avoid the risk of having the code execution blocked unexpectedly during random generation. Without this, the JVM uses `/dev/random`, which can block, to seed the `SecureRandom` class.
451
452
452
-
The authentication protocol requires a REST endpoint that issues challenge nonces as described in section *[6. Add a REST endpoint for issuing challenge nonces](#6-add-a-rest-endpoint-for-issuing-challenge-nonces)*.
453
+
The authentication protocol requires a filter that issues challenge nonces as described in section *[6. Add a filter for issuing challenge nonces](#6-add-a-filter-for-issuing-challenge-nonces)*.
453
454
454
455
Nonce usage is described in more detail in the [Web eID system architecture document](https://github.com/web-eid/web-eid-system-architecture-doc#authentication-1).
455
456
@@ -469,18 +470,18 @@ The `generateAndStoreNonce()` method both generates the nonce and saves it in th
469
470
470
471
## Extended configuration
471
472
472
-
The following additional configuration options are available in `NonceGeneratorBuilder`:
473
+
The following additional configuration options are available in `ChallengeNonceGeneratorBuilder`:
473
474
474
475
- `withNonceTtl(Duration duration)` – overrides the default challenge nonce time-to-live duration. When the time-to-live passes, the nonce is considered to be expired. Default challenge nonce time-to-live is 5 minutes.
475
476
- `withSecureRandom(SecureRandom)` - allows to specify a custom `SecureRandom` instance.
476
477
477
478
Extended configuration example:
478
479
```java
479
-
NonceGenerator generator = new NonceGeneratorBuilder()
480
-
.withChallengeNonceStore(store)
481
-
.withNonceTtl(Duration.ofMinutes(5))
482
-
.withSecureRandom(customSecureRandom)
483
-
.build();
480
+
ChallengeNonceGenerator generator = new ChallengeNonceGeneratorBuilder()
481
+
.withChallengeNonceStore(store)
482
+
.withNonceTtl(Duration.ofMinutes(5))
483
+
.withSecureRandom(customSecureRandom)
484
+
.build();
484
485
```
485
486
486
487
# Differences between version 1 and version 2
@@ -495,10 +496,9 @@ The Web eID authentication protocol defines two token formats currently supporte
495
496
496
497
- **Format v1.0** – Used in desktop Web eID authentication flows with traditional smart card readers.
497
498
498
-
- **Format v1.1** – An extended token format introduced for broader device compatibility and improved interoperability.
499
-
In addition to the fields present in v1.0, it includes:
500
-
- `unverifiedSigningCertificates` – an array of signing certificate entries. Each entry contains:
501
-
- `certificate` – a base64-encoded DER-encoded signing certificate;
502
-
- `supportedSignatureAlgorithms` – a list of supported signature algorithms associated with that certificate;
499
+
- **Format v1.1** – An extended authentication token format that allows including signing certificate information in the authentication response.
500
+
- `unverifiedSigningCertificates` – an array of signing certificate entries. Each entry contains:
501
+
- `certificate` – a base64-encoded DER-encoded signing certificate;
502
+
- `supportedSignatureAlgorithms` – a list of supported signature algorithms associated with that certificate;
503
503
504
504
Both token formats follow the same validation principles, differing only in the structure of embedded certificates and the additional verification steps required for v1.1.
0 commit comments