-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from privacybydesign/security-fixes
Security fixes, dependency updates, gradle upgrade, TomEE 9 support
- Loading branch information
Showing
21 changed files
with
586 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"java.configuration.updateBuildConfiguration": "automatic", | ||
"java.compile.nullAnalysis.mode": "automatic" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
FROM yarnpkg/node-yarn:latest as webappbuild | ||
|
||
ARG LANGUAGE=en | ||
|
||
# Build the webapp | ||
COPY ./webapp/ /webapp/ | ||
WORKDIR /webapp | ||
RUN yarn install && ./build.sh ${LANGUAGE} | ||
|
||
FROM gradle:7.6-jdk11 as javabuild | ||
|
||
# Build the java app | ||
COPY ./ /app/ | ||
WORKDIR /app | ||
RUN gradle build | ||
|
||
FROM tomee:9.1-jre11 | ||
|
||
# Copy the webapp to the webapps directory | ||
COPY --from=webappbuild /webapp/build/ /usr/local/tomee/webapps/ROOT/ | ||
|
||
# Copy the war file to the webapps directory | ||
COPY --from=javabuild /app/build/libs/irma_sms_issuer-1.0.war /usr/local/tomee/webapps/ | ||
|
||
EXPOSE 8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# irma_sms_issuer | ||
The IRMA SMS issuer takes care of issuing a mobile phone number to [Yivi app](https://github.com/privacybydesign/irmamobile) users. It consists of a Java backend API, which connects to an [irma server (issuer)](https://github.com/privacybydesign/irmago) and an SMS gateway service, and a frontend web app. | ||
|
||
# Running (development) | ||
The easiest way to run the irma_sms_issuer for development purposes is by having a phone with the Yivi app installed and Docker. | ||
|
||
### Setup listening for SMS messages: | ||
|
||
To be able to get the verification code execute [socat](http://www.dest-unreach.org/socat) in a separate terminal to intercept relevant local traffic: | ||
```bash | ||
$ socat -v TCP-LISTEN:8766,crlf,reuseaddr,fork SYSTEM:"echo HTTP/1.1 200" | ||
``` | ||
|
||
If you have an Android device you can also install [StartHere SMS Gateway App](https://m.apkpure.com/starthere-sms-gateway-app/com.bogdan.sms). This will give you a more visual experience. Make sure your development machine and phone are on the same network. And then, when the app is started, it runs a local server imitating an SMS sending gateway. SMS messages, in the form of POST requests coming from irma_sms_issuer, are sent to this messaging service and will be displayed inside the app. | ||
|
||
### Configuration | ||
Various configuration files, keys and settings need to be in place to be able to build and run the apps. | ||
|
||
1. To generate the required keys, run: | ||
```bash | ||
$ utils/keygen.sh ./src/main/resources/sk ./src/main/resources/pk | ||
``` | ||
|
||
2. Create the Java app configuration: | ||
Copy the file `src/main/resources/config.sample.json` to `src/main/resources/config.json` and set the `sms_sender_address` to match the IP address of your localhost or the Address displayed in the StartHere SMS Gateway app. For example: | ||
|
||
```json | ||
{ | ||
"sms_sender_address": "http://192.168.1.100:8766", | ||
} | ||
``` | ||
|
||
### Run | ||
Use docker-compose up combined with your localhost IP address as environment variable to spin up the containers: | ||
```bash | ||
$ IP=192.168.1.105 docker-compose up | ||
``` | ||
Note: do not use `127.0.0.1` or `0.0.0.0` as IP addresses as this will result in the app not being able to find the issuer. | ||
|
||
By default, docker-compose caches docker images, so on a second run the previous built images will be used. A fresh build can be enforced using the --build flag. | ||
```bash | ||
$ IP=192.168.1.105 docker-compose up --build | ||
``` | ||
|
||
Navigate to http://localhost:8080 in your browser and follow the instructions to test the complete flow. | ||
|
||
## Manually | ||
The Java api and JavaScript frontend can be built and run manually. To do so: | ||
|
||
### Build | ||
|
||
1. Generate JWT keys for the issuer | ||
```bash | ||
$ utils/keygen.sh ./src/main/resources/sk ./src/main/resources/pk | ||
``` | ||
|
||
2. Copy the file `src/main/resources/config.sample.json` to `src/main/resources/config.json` and modify it. | ||
|
||
3. Build the webapp: | ||
```bash | ||
$ cd webapp | ||
$ yarn install | ||
$ yarn build en | ||
``` | ||
The last command builds the English version of the webapp. To build another language, for example Dutch, run `yarn build nl` instead. | ||
|
||
4. Copy the file `webapp/config.example.js` to `webapp/build/assets/config.js` and modify it | ||
|
||
5. Run the following command in the root directory of this project: | ||
```bash | ||
$ gradle appRun | ||
``` | ||
|
||
To open the webapp navigate to http://localhost:8080/irma_sms_issuer. The API is accessible via http://localhost:8080/irma_sms_issuer/api. | ||
|
||
### Test | ||
You can run the tests, defined in `src/test/java/foundation/privacybydesign/sms/ratelimit`, using the following command: | ||
```bash | ||
$ gradle test | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
version: "3.8" | ||
name: irma_sms_issuer | ||
|
||
services: | ||
# Irma issuer service | ||
irmaserver: | ||
image: ghcr.io/privacybydesign/irma:v0.13.1 | ||
working_dir: /irmago | ||
ports: | ||
- 8088:8088 | ||
expose: | ||
- 8088 | ||
entrypoint: | ||
- "irma" | ||
- "server" | ||
- "--no-auth=false" | ||
- "--requestors={\"irma_sms_issuer\":{\"auth_method\":\"publickey\",\"key_file\": \"/config/pk.pem\"} }" | ||
- "--port=8088" | ||
- "--jwt-privkey-file=/config/sk.pem" | ||
- "--url=http://${IP}:8088" | ||
volumes: | ||
- ./src/main/resources/:/config/ | ||
|
||
# Service that runs the SMS issuer webapp and api | ||
irma_sms_issuer: | ||
platform: linux/x86_64 | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
environment: | ||
- IRMA_CONF=/config/ | ||
volumes: | ||
# Make keys and config.json available to Java app | ||
- ./src/main/resources/:/config/ | ||
# Make config.js available to webapp | ||
- ./webapp/config.example.js:/usr/local/tomee/webapps/ROOT/assets/config.js:ro" | ||
ports: | ||
- 8080:8080 | ||
expose: | ||
- 8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.4-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.