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
+154-9Lines changed: 154 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,20 +4,21 @@
4
4
5
5

6
6
7
-
The Web eID authentication token validation library for Java allows validating
7
+
The Web eID authentication token validation library for Java allows issuing challenge nonces and validating
8
8
Web eID JWT authentication tokens during authentication in web applications.
9
9
10
10
# Quickstart
11
11
12
-
Complete the steps below to add strong authentication support to your web application back end.
12
+
Complete the steps below to add strong authentication support to your web application back end. Instructions for the font end are available [here](https://github.com/web-eid/web-eid.js).
13
13
14
-
To run this quickstart you need a Java web application that uses Maven or Gradle to manage packages.
14
+
A Java web application that uses Maven or Gradle to manage packages is needed for running this quickstart.
15
+
Examples are for Maven, but they are straightforward to translate to Gradle.
15
16
16
-
See full example [here]().
17
+
See full example [here](https://github.com/web-eid/web-eid-spring-boot-example).
17
18
18
-
## 1. Add the library to your Maven or Gradle project
19
+
## 1. Add the library to your project
19
20
20
-
Add the following lines to Maven `pom.xml`:
21
+
Add the following lines to Maven `pom.xml` to include the Web eID authentication token validation library in your project:
21
22
22
23
```xml
23
24
<dependency>
@@ -36,12 +37,156 @@ Add the following lines to Maven `pom.xml`:
36
37
37
38
## 2. Add cache support
38
39
39
-
## 3. Add trusted certificate authorities
40
+
The validation library needs a cache for storing issued authentication tokens. Any *javax.cache.Cache* JSR107 API compatible implementation is suitable, we use Hazelcast here.
You must explicitly specify which certificate authorities (CAs) are trusted to issue the eID certificates for authentication.
103
+
CA certificates can be loaded from either the truststore file or any stream source.
104
+
We use the [`CertificateLoader`](https://github.com/web-eid/web-eid-authtoken-validation-java/blob/main/src/test/java/org/webeid/security/testutil/CertificateLoader.java) helper class from [`testutil`](https://github.com/web-eid/web-eid-authtoken-validation-java/tree/main/src/test/java/org/webeid/security/testutil) to load CA certificates from resouces here, but consider using [the truststore file](https://github.com/web-eid/web-eid-spring-boot-example/blob/main/src/main/java/org/webeid/example/config/ValidationConfiguration.java#L104-L122) instead.
105
+
106
+
First, copy the trusted certificates, for example `ESTEID-SK_2015.cer` and `ESTEID2018.cer`, to `resources/cacerts/`, then load the certificates as follows:
## 6. Add a REST endpoint for issuing challenge nonces
142
+
143
+
A REST endpoint that issues challenge nonces is required for authentication. The endpoint must support `GET` requests.
144
+
145
+
In the following example, we are using the [Spring RESTful Web Services framework](https://spring.io/guides/gs/rest-service/) to implement the endpoint, see also full implementation [here](https://github.com/web-eid/web-eid-spring-boot-example/blob/main/src/main/java/org/webeid/example/web/rest/ChallengeController.java).
Also, see general guidelines for implementing secure authentication services [here](https://github.com/SK-EID/smart-id-documentation/wiki/Secure-Implementation-Guide).
170
+
171
+
## 7. Implement authentication
172
+
173
+
Authentication consists of calling the `validate()` method of the authentication token validator. The internal implementation of the validation process is described in more detail below and in the [Web eID system architecture document](https://github.com/web-eid/web-eid-system-architecture-doc#authentication-1).
174
+
175
+
When using [Spring Security](https://spring.io/guides/topicals/spring-security-architecture) with standard cookie-based authentication,
176
+
177
+
- implement a custom authentication provider that uses the authentication token validator for authentication as shown [here](https://github.com/web-eid/web-eid-spring-boot-example/blob/main/src/main/java/org/webeid/example/security/AuthTokenDTOAuthenticationProvider.java),
178
+
- implement an AJAX authentication processing filter that extracts the authentication token and passes it to the authentication manager as shown [here](https://github.com/web-eid/web-eid-spring-boot-example/blob/main/src/main/java/org/webeid/example/security/WebEidAjaxLoginProcessingFilter.java),
179
+
- configure the authentication provider and authentication processing filter in the application configuration as shown [here](https://github.com/web-eid/web-eid-spring-boot-example/blob/main/src/main/java/org/webeid/example/config/ApplicationConfiguration.java).
180
+
181
+
The gist of the validation is [in the `authenticate()` method](https://github.com/web-eid/web-eid-spring-boot-example/blob/main/src/main/java/org/webeid/example/security/AuthTokenDTOAuthenticationProvider.java#L70-L72) of the authentication provider:
0 commit comments