Skip to content

Commit

Permalink
[Issue 2668] Setup local oauth2 server for API to connect to (#2806)
Browse files Browse the repository at this point in the history
## Summary
Fixes #{[2668](#2668)}

### Time to review: __5 mins__

## Changes proposed
Added Mock Oauth2 Server to api/docker-compose.yml 
Added custom config.json file with one test user 
Added custom mock-server-key.json file with one jwks key

## Context for reviewers
Pull mock server image specified in docker compose file and run it(Can
also use `make start`)
Can hit `http://localhost:5000/default/debugger` successfully 
`http://localhost:5000/issuer1/.well-known/openid-configuration` lists
endpoints you can hit.
  • Loading branch information
babebe authored Nov 13, 2024
1 parent 0361c72 commit 59fda82
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
15 changes: 15 additions & 0 deletions api/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,21 @@ services:
- grants_backend
- default

mock-oauth2-server:
image: ghcr.io/navikt/mock-oauth2-server:2.1.10
ports:
- "5001:5001"
environment:
LOG_LEVEL: "debug"
SERVER_PORT: 5001
CLIENT_ID: "api"
networks:
- grants_backend
- default
volumes:
- ./mock-oauth/config.json:/app/config.json
- ./mock-oauth/mock-server-key.json:/app/resources/mock-oauth2-server-keys.json

volumes:
grantsdbdata:
opensearch-data:
Expand Down
20 changes: 20 additions & 0 deletions api/mock-oauth/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"interactiveLogin": true,
"httpServer": "NettyWrapper",
"tokenCallbacks": [
{
"issuerId": "issuer1",
"tokenExpiry": 120,
"requestMappings": [
{
"requestParam": "code",
"match": "*",
"claims": {
"sub": "184c4c61-4a5d-4b5a-b3b9-bb9cfd7fe2ae",
"email": "[email protected]"
}
}
]
}
]
}
18 changes: 18 additions & 0 deletions api/mock-oauth/mock-server-key.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"keys": [
{
"p": "5riKsMcpImce_BGr13BQv6kA2RuRfW8aiqad7eu3WrdUPBZBGeI7LdISOYtikNij1GSuAnqLVyjPtKL1WDmNiKTo8ArvtZmlCNlEqQzzbUUIQFxUAJ9cMR_mgmoo-jfmia_0wPIVdMpev9Xzg30mAObNT0pj3F968e5ThSRave8",
"kty": "RSA",
"q": "tEM-X38gszZOAMwVZXQa_GEon3f9sngC6K1lX_TDbTdPoIHdberli70W2-505FEviEvtWf0VZGUbsxVIdWtN7rV9p-Q3__KnFYvj5dtIbZR1-Njgnleya9rmv_7pP3c_p66S0-jeEaXnLHorK3HOsvyzfuRM389BKwapKNdOGbs",
"d": "V19sUxBYchl1hbCrlYse7zLds_-lUCPI0xVaMhrw4OEmJhOqJqjNZtkDAcb7DsSyDW-L_Ai5XdXvOZoj8ZdqRO5eFEJtPpyRAmL7_4ZO2DT0ztyOCJu7xc2nBAFiTw25fk9aP2JxFEZTvCPoFMBFThsljS6A7_nvleVa8pD55s3LxBRojqmJZAPeO8he0ju2O2rAWsT8YJX7cgMUDBfE3eTR4riwQrIPh7fihcn0zVbf7DXDSMLaCeedc9EI17A00dwrPQx9eiqByatWMRTodzykTjAJGF06gtivBuVzJTTXUto3n9rBRp9pjxwp4o-u8-aZxJaZLIrDLJLgGv60aQ",
"e": "AQAB",
"use": "sig",
"kid": "initialkey-1",
"qi": "HqUVnJoG53wI1I3a922NDUWmVYxBa4fAA0nketVgSDbF5XkZTQW3JsC1K0oPqD-HtSz8bQu0JuOaG3ya-DVEGjeC8lpY_WX9rqoyBe-1AtqXOciU98iQwDIs5gARlTVj6q-jr867keNUdF8f9-GCFWqXWo0QFOeyXnOIwNRNJBo",
"dp": "V03XdUM3poP87odFTjV66Ltrzbun1x4WngakViZO8G3U2xPUuJWprRIDwXCj8Il5nOIoEloKpgWUaxcK3cKRcvZsCoEo6b_k-i800v9KkbuAftIxGzcyLIiUsh63uM80Vj-VzvkL83CsX8z243eUzNyJLgrJNNeQb0Guqv_xslM",
"alg": "RS256",
"dq": "pKUijDDeWjHIjzvYcyDYIRpQ806yftbUuVbe2AUElnXFmfHjoKjC3p5oCZtEUuHAS3omIWJirp8W7LwMwYqv1M8aJUXyzCkC6VAraN-fyM6n7hGRH68z_QUka8rVmi0-C9cMrtbsNixU-K_hTD4XsC3VeJnniSiQ-k6MJQx6fk8",
"n": "onZcB1ryWS1keTIcbgsLKJ1UBwL1Wbzse5P2HjkrNwbG3Jy2lefUEcTVJxN8bpLeW460Luz3ScZd3d9p8IoHjmhZ2cyO49E41aBRIlBRzWNpebK5xeC95rSKenYHpOPlLzPgybg2qxallzQUOcKCheiF0fsErlapaA9YmKwzP3DwvzYW4JqSrHhDGWPwUCcsR4dpetwKXP_9tRFso06ryr4um3qiq7giyZEyZVG3fHMplD-5e-2-RrzBiGFW_zvs-XVRGPIf9Y5YNjeQJRuS4vF82V8mNZxEZddtUY5plSz-vgX3GSvANLDH-LZJ76Zmx3a8dEZbI7VxgsBQAqcUlQ"
}
]
}

0 comments on commit 59fda82

Please sign in to comment.