-
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.
Mise en place d'un serveur d'auth OIDC _mocké_
- Loading branch information
1 parent
af5ea9c
commit 8a10ecc
Showing
13 changed files
with
768 additions
and
172 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 @@ | ||
server { | ||
listen 443 ssl; | ||
listen [::]:443 ssl; | ||
http2 on; | ||
|
||
# SSL | ||
ssl_certificate /etc/nginx/certs/proconnect.anje-justice.test.pem; | ||
ssl_certificate_key /etc/nginx/certs/proconnect.anje-justice.test-key.pem; | ||
ssl_trusted_certificate /etc/nginx/certs/rootCA.pem; | ||
|
||
server_name proconnect.anje-justice.test; | ||
|
||
location / { | ||
# Allow performing host detection on request | ||
resolver 127.0.0.11 valid=1s; | ||
set $upstream proconnect:9998; | ||
|
||
proxy_http_version 1.1; | ||
proxy_cache_bypass $http_upgrade; | ||
proxy_set_header Host $host; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-Host $host; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
proxy_set_header X-Forwarded-Port $server_port; | ||
|
||
proxy_pass http://$upstream; | ||
} | ||
} | ||
|
||
server { | ||
listen 80; | ||
listen [::]:80; | ||
|
||
server_name proconnect.anje-justice.test; | ||
|
||
location / { | ||
return 301 https://proconnect.anje-justice.test/$request_uri; | ||
} | ||
} |
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,2 @@ | ||
dist/ | ||
node_modules/ |
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,17 @@ | ||
{ | ||
"name": "mock-oidc-provider", | ||
"version": "0.1.0", | ||
"type": "module", | ||
"description": "Mock OIDC provider server", | ||
"main": "dist/index.js", | ||
"author": "Pierre LEMEÉ", | ||
"license": "MIT", | ||
"private": true, | ||
"dependencies": { | ||
"oauth2-mock-server": "^7.2.0" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^22.10.7", | ||
"typescript": "^5.7.3" | ||
} | ||
} |
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,52 @@ | ||
import { OAuth2Server } from 'oauth2-mock-server'; | ||
|
||
let server = new OAuth2Server(); | ||
|
||
// use JWKs generated here https://mkjwk.org/ | ||
await server.issuer.keys.add({ | ||
"p": "9B6mboyeh7j8KBWFyL-Sxgta-RRcnxqm4Ey_1vYvCV_R9PgZhLzkIOLSoBqxqBn5m6spcuOTmLDBXrdmxvyVIuIuLJTMbg9MrO9H7GgbLYVMSumHFsk6NZFKlDGmA4HfEk0RKQwctIFNhCJnvE8NDQP0enyl3Ii32WjttM9gmtM", | ||
"kty": "RSA", | ||
"q": "8d4BwO1jgFK_DvWlwVMhxbhwX4IEuBaqe7HU0qGRCwAHqPe5_2jsBliP-Cyaqj4oeNFyNpVyBupGAy5md6YsicvFg2IOVwX0eQNGIvxIcFofTyc5q9eV3ppZxVVt01MVKHJ62269CAMp3pTOYgYzUhA9ltVy0V-g8xfcjZ3rycE", | ||
"d": "jsUelRMiqCRnXlYTOBqjBOqOmyjgMqFDXRlSyHbaVaRAjO_9-awCzD8kTKLEZdsqaaXbrVcAyqWF7up4YKs8Ogz5YPQ8RMhysC-Wg786m-Z4fsH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3uxpOdVklY40rfaAYy6yf8BBDR_W0GCLhbEj8dmeVsqhIoss5ISdUvj4M7gKgkPdBxcwuDRPR2J2QSGMOg8MGTNJSnjkC6fYqTmGk1Ab_4gcO-1mAqq0XJP5nSOTHpmV_Cz3DbnSHmL7uBVkEw" | ||
}); | ||
await server.issuer.keys.add({ | ||
"kty": "EC", | ||
"d": "QVZNI6vv0NEshgrd8JzYm3JA3YomEnm8j9a_gBuh3G8", | ||
"use": "sig", | ||
"crv": "P-256", | ||
"kid": "Jh9D8jQqOfbNi4AM1r8-mKU_KOpeMbjGRduPyDXxVy4", | ||
"x": "SiYrczxd1TP6NXuDTNp3KqBsVKm7yEIBqCUp3_fiaS8", | ||
"y": "1OI5MJQ2JhMtODX8WLVzGP-5tRPU-131I58AD0yg2sM", | ||
"alg": "ES256" | ||
}); | ||
|
||
server.issuer.url = "https://proconnect.anje-justice.test" | ||
server.service.once('beforeAuthorizeRedirect', (authorizeRedirectUri, req) => { | ||
console.log(authorizeRedirectUri); | ||
}); | ||
|
||
server.service.once('beforeUserinfo', (userInfoResponse, req) => { | ||
userInfoResponse.body = { | ||
sub: 'c1722a03-4172-4015-9f0d-d1995d4cbe5c', | ||
email: 'redacteur@test.fr', | ||
usual_name: "Chantal", | ||
given_name: "Redacteur", | ||
uid: '1234', | ||
idp_id: 'fce74da7-34d5-4b59-ba78-828a97d859cf' | ||
}; | ||
}); | ||
|
||
// Start the server | ||
await server.start(parseInt(process.env.PORT || "9998", 10), '0.0.0.0'); | ||
console.log('Issuer URL:', server.issuer.url); | ||
|
||
// Stop the server | ||
// await server.stop(); |
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,20 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ESNext", | ||
"module": "NodeNext", | ||
"esModuleInterop": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"strict": true, | ||
"skipLibCheck": true, | ||
"outDir": "dist", | ||
"rootDir": "src", | ||
"sourceMap": true, | ||
"experimentalDecorators": true, | ||
"moduleResolution": "nodenext", | ||
"resolveJsonModule": true, | ||
"types": [ | ||
"node", | ||
] | ||
}, | ||
"include": ["src"] | ||
} |
Oops, something went wrong.