-
Notifications
You must be signed in to change notification settings - Fork 0
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 #16 from swisscom/feature/32591-authenticate
Feature/32591 authenticate
- Loading branch information
Showing
29 changed files
with
668 additions
and
42 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
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,12 @@ | ||
{ | ||
http_port 8080 | ||
https_port 8443 | ||
} | ||
localhost { | ||
reverse_proxy /isalive mock-oauth2-server:8080 | ||
} | ||
login.microsoftonline.com { | ||
tls internal | ||
reverse_proxy /common/discovery/* wiremock:8080 | ||
reverse_proxy /test-tenant-id/* mock-oauth2-server: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,3 @@ | ||
FROM caddy:2.8.4 | ||
RUN apk update && apk upgrade && apk add curl | ||
COPY ./Caddyfile /etc/caddy/Caddyfile |
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,12 +1,61 @@ | ||
services: | ||
wiremock: | ||
image: local.wiremock.cdrapi | ||
container_name: wiremock-cdr-client | ||
build: ./wiremock | ||
mem_limit: 256m | ||
healthcheck: | ||
# use a mapped URL for health checking; the response is a 200 OK with a string body "OK" | ||
test: curl --fail http://localhost:8080/health || exit 1 | ||
interval: 5s | ||
retries: 5 | ||
start_period: 5s | ||
timeout: 10s | ||
ports: | ||
- "9090:8080" | ||
- "8443:8443" | ||
- "9090:8080" | ||
environment: | ||
- TZ=Europe/Zurich | ||
command: ["--verbose", "--https-port", "8443", "--global-response-templating"] | ||
networks: | ||
- cdr_client_net | ||
|
||
mock-oauth2-server: | ||
image: ghcr.io/navikt/mock-oauth2-server:2.1.10 | ||
container_name: mock-oauth2-server-cdr-client | ||
environment: | ||
- TZ=Europe/Zurich | ||
- LOG_LEVEL=DEBUG | ||
- JSON_CONFIG_PATH=/app/config.json | ||
- SERVER_PORT=8080 | ||
volumes: | ||
- ./mockOAuth2Server/config.json:/app/config.json | ||
- ./mockOAuth2Server/mockoauth2server.p12:/app/mockoauth2server.p12 | ||
networks: | ||
- cdr_client_net | ||
|
||
caddy: | ||
depends_on: | ||
wiremock: | ||
condition: service_healthy | ||
image: local.caddy.cdrappmgr | ||
container_name: caddy-app-mgr | ||
build: ./caddy | ||
mem_limit: 256m | ||
ports: | ||
- "8443:8443" | ||
healthcheck: | ||
# checks the mock-oauth2-server's health endpoint to prove that both caddy and the mock-oauth2-server are up and running | ||
test: curl --insecure --fail https://localhost:8443/isalive || exit 1 | ||
interval: 5s | ||
retries: 5 | ||
start_period: 120s | ||
timeout: 10s | ||
networks: | ||
- cdr_client_net | ||
|
||
networks: | ||
cdr_client_net: | ||
name: cdr_client_net | ||
ipam: | ||
config: | ||
- subnet: 10.113.0.0/16 |
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,44 @@ | ||
# TLS Keystore For MockOAuth2Server | ||
|
||
Run your [own CA](https://pki-tutorial.readthedocs.io/en/latest/simple/) and issue yourself a | ||
[key pair](./mockoauth2server.p12).<br> | ||
If you want/need to repeat the process: | ||
|
||
1. check out the 2022 branch (or whatever branch appears to be the most up-to-date one) of this | ||
[git repo](https://bitbucket.org/stefanholek/pki-example-1) and | ||
2. change the policy "match_pol" of the signing ca config file to mark all fields as "supplied" so you get to set | ||
the `DC`, `OU`, and `O` parts of the X509 certificate yourself: | ||
```shell | ||
diff work/git/3rd_party/pki-example-1/etc/signing-ca.conf work/software/ca/etc/signing-ca.conf | ||
68,70c68,70 | ||
< domainComponent = match # Must match 'simple.org' | ||
< organizationName = match # Must match 'Simple Inc' | ||
< organizationalUnitName = optional # Included if present | ||
--- | ||
> domainComponent = supplied # Must match 'simple.org' | ||
> organizationName = supplied # Must match 'Simple Inc' | ||
> organizationalUnitName = supplied # Included if present | ||
``` | ||
3. follow the instructions to initialize the root and signing CAs (step 1 and 2) | ||
4. create a sub-folder `certs` | ||
5. then generated a new key pair for the Oauth2 Mock Server like so (note that the `SAN` must match the service name in | ||
the [docker-compose.yml](../docker-compose.yaml)): | ||
```shell | ||
SAN=DNS:mock-oauth2-server,DNS:localhost,DNS:host.docker.internal \ | ||
openssl req -new \ | ||
-config etc/server.conf \ | ||
-out certs/mockoauth2server.csr \ | ||
-keyout certs/mockoauth2server.key | ||
openssl ca \ | ||
-config etc/signing-ca.conf \ | ||
-in certs/mockoauth2server.csr \ | ||
-out certs/mockoauth2server.crt \ | ||
-extensions server_ext | ||
openssl pkcs12 -export \ | ||
-name "OAuth2 Local Development" \ | ||
-inkey certs/mockoauth2server.key \ | ||
-in certs/mockoauth2server.crt \ | ||
-out certs/mockoauth2server.p12 | ||
``` |
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,30 @@ | ||
{ | ||
"interactiveLogin": false, | ||
"httpServer": { | ||
"type": "NettyWrapper" | ||
}, | ||
"tokenProvider" : { | ||
"keyProvider" : { | ||
"algorithm" : "ES256" | ||
} | ||
}, | ||
"tokenCallbacks": [ | ||
{ | ||
"issuerId": "test-tenant-id/oauth2/v2.0", | ||
"tokenExpiry":360, | ||
"requestMappings": [ | ||
{ | ||
"requestParam": "client_id", | ||
"match": "*", | ||
"claims": { | ||
"sub": "${clientId}", | ||
"roles": [ | ||
"CdrApi.ReadWrite.OwnedBy", | ||
"AppRoleAssignment.ReadWrite.All" | ||
] | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} |
Binary file not shown.
Oops, something went wrong.