Skip to content

Commit

Permalink
SDK-2230: Add example for share v2
Browse files Browse the repository at this point in the history
  • Loading branch information
irotech committed Aug 2, 2023
1 parent 8d59320 commit e8ca9f6
Show file tree
Hide file tree
Showing 20 changed files with 968 additions and 648 deletions.
2 changes: 2 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<!-- plugin versions -->
<maven-deploy-plugin.version>3.1.1</maven-deploy-plugin.version>
<properties-maven-plugin.version>1.1.0</properties-maven-plugin.version>
<spotbugs-maven-plugin.version>4.7.3.4</spotbugs-maven-plugin.version>
</properties>

<build>
Expand Down Expand Up @@ -59,6 +60,7 @@
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>${spotbugs-maven-plugin.version}</version>
</plugin>
</plugins>
</build>
Expand Down
58 changes: 32 additions & 26 deletions yoti-sdk-spring-boot-example/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# Spring Boot Yoti SDK Example
# Spring Boot Yoti SDK Examples
This project shows example implementations of a server-app with an endpoint which will be called by Yoti

This project shows an example implementation of a server-app with an endpoint which will be called by Yoti with a `token`.
You will need to pass this token to Yoti-SDK in order to retrieve the profile of a user which has been logged in by Yoti.
# Prerequisites
Before you start, you'll need to create an Application in [Yoti Hub](https://hub.yoti.com) and set the domain to `https://localhost:8443/`

Before you start, you'll need to create an Application in [Yoti Hub](https://hub.yoti.com) and verify the domain.

**NOTE: While creating Application in Yoti Hub, some of the attributes (except phone number and selfie) require users to have a Yoti with a verified passport. If your application, for instance, requires the user's date of birth and she/he has not added their passport to their Yoti account, this will lead to a failed login.**
Note that:
- Your endpoint must be accessible from the machine that is displaying the QR code.**
- In order to receive calls on endpoint, you need to expose your server-app to the outside world. We require that you use the domain from the Callback URL and HTTPS
- While creating Application in Yoti Hub, some of the attributes (except phone number and selfie) require users to have a Yoti with a verified passport. If your application, for instance, requires the user's date of birth and she/he has not added their passport to their Yoti account, this will lead to a failed login

## Project Structure
* The logic for retrieving the profile can be found in `com.yoti.api.examples.springboot.YotiLoginController#doLogin`.
* `resources/app-keypair.pem` is the keypair you can get from Yoti Hub.
* `resource/application.yml` contains the configuration that enforces SSL usage by your server-app (in case you are not using a proxy server like NGINX). Make sure that you update the SDK Application ID and the configuration points to the right path to the java keystore with an SSL key (there is an already one included in the project ``` server.keystore.jks ```).
* `resources/application.yml` contains the configuration that enforces SSL usage by your server-app (in case you are not using a proxy server like NGINX). Make sure that you update the SDK Application ID and the configuration points to the right path to the java keystore with an SSL key (there is an already one included in the project ``` server.keystore.jks ```).
* This project contains a Spring-boot server application. In this example we used the current SDK version by including the specific Maven dependency with its repository:
```xml
<dependency>
Expand All @@ -20,26 +21,31 @@ Before you start, you'll need to create an Application in [Yoti Hub](https://hub
</dependency>
```

## Building your example server-app
1. In the [Yoti Hub](https://hub.yoti.com) set the application domain of your app to `https://localhost:8443/`. Note that your endpoint must be accessible from the machine that is displaying the QR code.
1. Still in the Hub, set the scenario callback URL to `/login`.
1. Copy the [resources/application.yml.example](src/main/resources/application.yml.example) and create a new file `resources/application.yml`
1. Edit the `resources/application.yml` and replace the `yoti-client-sdk-id-from-hub` value with the `Yoti client SDK ID` you can find in Yoti Hub.
1. Download your Application's key pair from Yoti Hub and copy it to `resources/app-keypair.pem`.
1. Run `mvn clean package` to build the project.

## Running
* You can run your server-app by executing `java -jar target/yoti-sdk-spring-boot-example-3.8.0-SNAPSHOT.jar`
* If you are using Java 9, you can run the server-app as follows `java -jar target/yoti-sdk-spring-boot-example-3.8.0-SNAPSHOT.jar --add-exports java.base/jdk.internal.ref=ALL-UNNAMED`
## Building your server-app and run the example
* Copy the [application.yml.example](src/main/resources/application.yml.example) and rename it to `application.yml`
* Edit the newly renamed file and replace `yoti-client-sdk-id-from-hub` value with `Yoti client SDK ID` you can find in Yoti Hub
* Download your Application's key pair from Yoti Hub and save it to `resources/app-keypair.pem`
* Run `mvn clean package` to build the project

### Share v1
* In the Hub, set the scenario callback URL to `/login`.
* In order to receive calls on your /login endpoint, you need to expose your server-app to the outside world.
* You **must** use the domain from the Callback URL and HTTPS
* You can run your server-app by executing `java -jar target/yoti-sdk-spring-boot-example.jar`
* Navigate to:
* `https://localhost:8443` to initiate a login using Yoti. The Spring demo is listening for the response on `https://localhost:8443/login`.
* `https://localhost:8443/dynamic-share` to initiate a dynamic share with location with result displayed in profile page.
* `https://localhost:8443/dbs-check` to initiate a BDS standard check with location with result displayed in profile page.
* [https://localhost:8443](https://localhost:8443) to initiate a login using Yoti. The Spring demo is listening for the response on `https://localhost:8443/login`
* [https://localhost:8443/dynamic-share](https://localhost:8443/dynamic-share) to initiate a dynamic share with location with result displayed in profile page.
* [https://localhost:8443/dbs-check](https://localhost:8443/dbs-check) to initiate a BDS standard check with location with result displayed in profile page.

In order to receive calls on your /login endpoint, you need to expose your server-app to the outside world. We require that you use the domain from the Callback URL and HTTPS.
The logic for all the v1 share examples can be found in the `YotiLoginController`

## Requirements for running the application
* Java 8 or above
* If you are using Oracle JDK/JRE you need to install JCE extension in your server's Java to allow strong encryption (http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html). This is not a requirement if you are using OpenJDK.
### Share v2
* You can run your server-app by executing `java -jar -Dyoti.api.url="https://api.yoti.com/share" target/yoti-sdk-spring-boot-example.jar`. The JVM argument is required to override the default `https://api.yoti.com/api/v1`
* Navigate to:
* [https://localhost:8443/v2/digital-identity-share](https://localhost:8443/v2/digital-identity-share) to initiate a login using the Yoti share v2

The logic for the v2 share example session creation and receipt can be found respectively in the `IdentitySessionController` and `IdentityLoginController`

## Requirements for running the application
* Java 8 or above
* If you are using Oracle JDK/JRE you need to install JCE extension in your server's Java to allow strong encryption (http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html). This is not a requirement if you are using OpenJDK
3 changes: 3 additions & 0 deletions yoti-sdk-spring-boot-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<supported.java.release.version>8</supported.java.release.version>

<guava.version>32.1.1-jre</guava.version>
<spotbugs-maven-plugin.version>4.7.3.4</spotbugs-maven-plugin.version>
</properties>

<licenses>
Expand Down Expand Up @@ -92,6 +93,7 @@
</dependencies>

<build>
<finalName>${project.artifactId}</finalName>
<pluginManagement>
<plugins>
<plugin>
Expand All @@ -118,6 +120,7 @@
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>${spotbugs-maven-plugin.version}</version>
</plugin>
</plugins>
</build>
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit e8ca9f6

Please sign in to comment.