Module for mocking authentication
- Java 11
- Maven
The module can be run either as a jar running on localhost, in a docker container from local image, or a docker container from an image hosted on Informasjonsforvaltnings package repository
In project root:
Run mvn clean install
to build the project
-
Running from commandline:
java -jar ./target/auth-utils-java-1.0-SNAPSHOT-jar-with-dependencies.jar
-
Running in docker container
docker container run -p 8084:8084 --name auth auth-utils-java
In application-dev.properties file add line:
security.oauth2.resource.jwk.key-set-uri: http://localhost:8084/jwk
set env variable SPRING_ACTIVE_PROFILE�
to dev
on startup
curl http://localhost:8084/jwt/read
curl http://localhost:8084/jwt/write
curl http://localhost:8084/jwt/admin
Default: 8084
-
In terminal
java -jar -custom.port=8201 ./target/auth-utils-java-1.0-SNAPSHOT-jar-with-dependencies.jar
-
In docker: change hostport mapping
docker container run -p 8021:8084 --name auth auth-utils-java
�
format: [type]:[orgnumber]:[rights]
default: organisation:910244132:[rights]
-
In terminal:
java -jar -Dcustom.type=different -Dcustom.org=91919191 ./target/auth-utils-java-1.0-SNAPSHOT-jar-with-dependencies.jar
-
In docker you change type by setting env variables
type
,port
andorg
docker container run -p 8084:8084 -e type='different' --name auth auth-utils-java
-
In docker with .env file
container run -p 8084:8084 --env-file ./env.list --name auth auth-utils-java
see env.list for an example.
Append pararmeters type
and/or org
to your jwt request
curl localhost:8084/jwt/read?org=6786876
curl localhost:8084/jwt/write?org=6786876&type=special
curl localhost:8084/jwt/write?type=special
-
In terminal seperated by comma:
java -jar -Dcustom.aud=other-audience,yet-another-audience ./target/auth-utils-java-1.0-SNAPSHOT-jar-with-dependencies.jar
-
In docker you change type by setting the env variable
aud
docker container run -p 8084:8084 -e aud=other-audience,yet-another-audience --name auth auth-utils-java
Update val audience
in JwtToken.java
and rebuild image
See FAQ for more on audience and access string