Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MDS-5751] Add environment variable for OIDC test keys #3104

Merged
merged 15 commits into from
May 17, 2024
35 changes: 34 additions & 1 deletion services/document-manager/backend/.env-example
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,37 @@ OTEL_TRACES_EXPORTER=otlp
OTEL_SERVICE_NAME=mds_document_manager
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://otelcollector:4317
OTEL_METRICS_EXPORTER=none
OTEL_LOG_LEVEL=debug
OTEL_LOG_LEVEL=debug

JWT_OIDC_TEST_AUDIENCE=test_audience
JWT_OIDC_TEST_CLIENT_SECRET=test_secret
JWT_OIDC_TEST_ISSUER=test_issuer
JWT_OIDC_KEY_KID=flask-jwt-oidc-test-client
JWT_OIDC_KEY_KTY=RSA
JWT_OIDC_KEY_ALG=RS256
JWT_OIDC_KEY_USE=sig
JWT_OIDC_KEY_N='AN-fWcpCyE5KPzHDjigLaSUVZI0uYrcGcc40InVtl-rQRDmAh-C2W8H4_Hxhr5VLc6crsJ2LiJTV_E72S03pzpOOaaYV6-TzAjCou2GYJIXev7f6Hh512PuG5wyxda_TlBSsI-gvphRTPsKCnPutrbiukCYrnPuWxX5_cES9eStR'
JWT_OIDC_KEY_E=AQAB
JWT_OIDC_KEY_D='C0G3QGI6OQ6tvbCNYGCqq043YI_8MiBl7C5dqbGZmx1ewdJBhMNJPStuckhskURaDwk4-8VBW9SlvcfSJJrnZhgFMjOYSSsBtPGBIMIdM5eSKbenCCjO8Tg0BUh_xa3CHST1W4RQ5rFXadZ9AeNtaGcWj2acmXNO3DVETXAX3x0'
JWT_OIDC_KEY_P='APXcusFMQNHjh6KVD_hOUIw87lvK13WkDEeeuqAydai9Ig9JKEAAfV94W6Aftka7tGgE7ulg1vo3eJoLWJ1zvKM'
JWT_OIDC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jWFO9KQqArQL1V8w2D4aCd0uJULiC9pCP7aTHvBhcCQQDb
W0mOp436T6ZaELBfbFNulNLOzLLi5YzNRPLppfG1SRNZjbIrvTIKVL4N/YxLvQbT
NrQw+2OdQACBJiEHsdZzAkBcsTk7frTH4yGx0VfHxXDPjfTj4wmD6gZIlcIr9lZg
4H8UZcVFN95vEKxJiLRjAmj6g273pu9kK4ymXNEjWWJn
-----END RSA PRIVATE KEY-----'
88 changes: 36 additions & 52 deletions services/document-manager/backend/app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,67 +175,51 @@ class TestConfig(Config):
SQLALCHEMY_DATABASE_URI = DB_URL

JWT_OIDC_TEST_MODE = True
JWT_OIDC_TEST_AUDIENCE = "test_audience"
JWT_OIDC_TEST_CLIENT_SECRET = "test_secret"
JWT_OIDC_TEST_ISSUER = "test_issuer"
JWT_OIDC_TEST_AUDIENCE = os.environ.get('JWT_OIDC_TEST_AUDIENCE', None)
JWT_OIDC_TEST_CLIENT_SECRET = os.environ.get('JWT_OIDC_TEST_CLIENT_SECRET', None)
JWT_OIDC_TEST_ISSUER = os.environ.get('JWT_OIDC_TEST_ISSUER', None)

KID_KEY = os.environ.get('JWT_OIDC_KEY_KID', None)
KTY_KEY = os.environ.get('JWT_OIDC_KEY_KTY', None)
ALG_KEY = os.environ.get('JWT_OIDC_KEY_ALG', None)
USE_KEY = os.environ.get('JWT_OIDC_KEY_USE', None)
N_KEY = os.environ.get('JWT_OIDC_KEY_N', None)
E_KEY = os.environ.get('JWT_OIDC_KEY_E', None)
D_KEY = os.environ.get('JWT_OIDC_KEY_D', None)
P_KEY = os.environ.get('JWT_OIDC_KEY_P', None)
Q_KEY = os.environ.get('JWT_OIDC_KEY_Q', None)
DP_KEY = os.environ.get('JWT_OIDC_KEY_DP', None)
DQ_KEY = os.environ.get('JWT_OIDC_KEY_DQ', None)
QI_KEY = os.environ.get('JWT_OIDC_KEY_QI', None)

# Dummy Private Keys for testing purposes, can replace these keys with any other generated key.
JWT_OIDC_TEST_KEYS = {
"keys": [{
"kid": "flask-jwt-oidc-test-client",
"kty": "RSA",
"alg": "RS256",
"use": "sig",
"n":
"AN-fWcpCyE5KPzHDjigLaSUVZI0uYrcGcc40InVtl-rQRDmAh-C2W8H4_Hxhr5VLc6crsJ2LiJTV_E72S03pzpOOaaYV6-TzAjCou2GYJIXev7f6Hh512PuG5wyxda_TlBSsI-gvphRTPsKCnPutrbiukCYrnPuWxX5_cES9eStR",
"e": "AQAB"
"kid":KID_KEY,
"kty":KTY_KEY,
"alg":ALG_KEY,
"use":USE_KEY,
"n":N_KEY,
"e":E_KEY
}]
}
# Dummy Private Keys for testing purposes.
JWT_OIDC_TEST_PRIVATE_KEY_JWKS = {
"keys": [{
"kid":
"flask-jwt-oidc-test-client",
"kty":
"RSA",
"alg":
"RS256",
"use":
"sig",
"kty":
"RSA",
"n":
"AN-fWcpCyE5KPzHDjigLaSUVZI0uYrcGcc40InVtl-rQRDmAh-C2W8H4_Hxhr5VLc6crsJ2LiJTV_E72S03pzpOOaaYV6-TzAjCou2GYJIXev7f6Hh512PuG5wyxda_TlBSsI-gvphRTPsKCnPutrbiukCYrnPuWxX5_cES9eStR",
"e":
"AQAB",
"d":
"C0G3QGI6OQ6tvbCNYGCqq043YI_8MiBl7C5dqbGZmx1ewdJBhMNJPStuckhskURaDwk4-8VBW9SlvcfSJJrnZhgFMjOYSSsBtPGBIMIdM5eSKbenCCjO8Tg0BUh_xa3CHST1W4RQ5rFXadZ9AeNtaGcWj2acmXNO3DVETXAX3x0",
"p":
"APXcusFMQNHjh6KVD_hOUIw87lvK13WkDEeeuqAydai9Ig9JKEAAfV94W6Aftka7tGgE7ulg1vo3eJoLWJ1zvKM",
"q":
"AOjX3OnPJnk0ZFUQBwhduCweRi37I6DAdLTnhDvcPTrrNWuKPg9uGwHjzFCJgKd8KBaDQ0X1rZTZLTqi3peT43s",
"dp":
"AN9kBoA5o6_Rl9zeqdsIdWFmv4DB5lEqlEnC7HlAP-3oo3jWFO9KQqArQL1V8w2D4aCd0uJULiC9pCP7aTHvBhc",
"dq":
"ANtbSY6njfpPploQsF9sU26U0s7MsuLljM1E8uml8bVJE1mNsiu9MgpUvg39jEu9BtM2tDD7Y51AAIEmIQex1nM",
"qi":
"XLE5O360x-MhsdFXx8Vwz4304-MJg-oGSJXCK_ZWYOB_FGXFRTfebxCsSYi0YwJo-oNu96bvZCuMplzRI1liZw"
"kid":KID_KEY,
"kty":KTY_KEY,
"alg":ALG_KEY,
"use":USE_KEY,
"kty":KTY_KEY,
"n":N_KEY,
"e":E_KEY,
"d":D_KEY,
"p":P_KEY,
"q":Q_KEY,
"dp":DP_KEY,
"dq":DQ_KEY,
"qi":QI_KEY
}]
}
# Dummy Private Key, for testing purposes.
JWT_OIDC_TEST_PRIVATE_KEY_PEM = """
-----BEGIN RSA PRIVATE KEY-----
MIICXQIBAAKBgQDfn1nKQshOSj8xw44oC2klFWSNLmK3BnHONCJ1bZfq0EQ5gIfg
tlvB+Px8Ya+VS3OnK7Cdi4iU1fxO9ktN6c6TjmmmFevk8wIwqLthmCSF3r+3+h4e
ddj7hucMsXWv05QUrCPoL6YUUz7Cgpz7ra24rpAmK5z7lsV+f3BEvXkrUQIDAQAB
AoGAC0G3QGI6OQ6tvbCNYGCqq043YI/8MiBl7C5dqbGZmx1ewdJBhMNJPStuckhs
kURaDwk4+8VBW9SlvcfSJJrnZhgFMjOYSSsBtPGBIMIdM5eSKbenCCjO8Tg0BUh/
xa3CHST1W4RQ5rFXadZ9AeNtaGcWj2acmXNO3DVETXAX3x0CQQD13LrBTEDR44ei
lQ/4TlCMPO5bytd1pAxHnrqgMnWovSIPSShAAH1feFugH7ZGu7RoBO7pYNb6N3ia
C1idc7yjAkEA6Nfc6c8meTRkVRAHCF24LB5GLfsjoMB0tOeEO9w9Ous1a4o+D24b
AePMUImAp3woFoNDRfWtlNktOqLel5PjewJBAN9kBoA5o6/Rl9zeqdsIdWFmv4DB
5lEqlEnC7HlAP+3oo3jWFO9KQqArQL1V8w2D4aCd0uJULiC9pCP7aTHvBhcCQQDb
W0mOp436T6ZaELBfbFNulNLOzLLi5YzNRPLppfG1SRNZjbIrvTIKVL4N/YxLvQbT
NrQw+2OdQACBJiEHsdZzAkBcsTk7frTH4yGx0VfHxXDPjfTj4wmD6gZIlcIr9lZg
4H8UZcVFN95vEKxJiLRjAmj6g273pu9kK4ymXNEjWWJn
-----END RSA PRIVATE KEY-----"""
JWT_OIDC_TEST_PRIVATE_KEY_PEM = os.environ.get('JWT_OIDC_TEST_PRIVATE_KEY_PEM', None)
Loading