Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Informasjonsforvaltning/auth-utils-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Auth utils java

Overview

Module for mocking authentication

Requirements

  • Java 11
  • Maven

Running

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

Setup

In project root:
Run mvn clean install to build the project

  1. Running from commandline:
    java -jar ./target/auth-utils-java-1.0-SNAPSHOT-jar-with-dependencies.jar

  2. Running in docker container
    docker container run -p 8084:8084 --name auth auth-utils-java

Add module as jwk store in spring

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

Get jwt

curl http://localhost:8084/jwt/read
curl http://localhost:8084/jwt/write
curl http://localhost:8084/jwt/admin

Customization

Change port

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

Change access string type

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 and org
    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.

Change in request

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

Audience

Updating audience temporarily

  • 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

Updating audience permanently

Update val audience in JwtToken.java and rebuild image

See FAQ for more on audience and access string

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages