Skip to content

Commit

Permalink
Added separated keys for signing and encryption in RP and OP tests (#312
Browse files Browse the repository at this point in the history
)

* feat: added get_client_organisation_name method to retrieve the correct RP name

* chore: fix CIE organization_name

* fix: updated cryptography rsa import to 42.0.2

* chore: bump to 1.3.1

* fix: corrected proposed change

* fix: scope issue

* Update spid_cie_oidc/provider/views/consent_page_view.py

Co-authored-by: Giuseppe De Marco <[email protected]>

* Update spid_cie_oidc/provider/views/__init__.py

Co-authored-by: Giuseppe De Marco <[email protected]>

* Update spid_cie_oidc/provider/views/authz_request_view.py

Co-authored-by: Giuseppe De Marco <[email protected]>

* fix: reinstated method name

* feat: distinction between sig and enc keys during RP and OP operations

* fix: better function for key retrivial

* fix: added encryption algs to jwk validator

* test: added separated keys for signing and encryption in RP and OP tests

* chore: bump to version 1.4.1

---------

Co-authored-by: Giuseppe De Marco <[email protected]>
  • Loading branch information
rglauco and Giuseppe De Marco authored Mar 14, 2024
1 parent 54f8e88 commit 9d86451
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 20 deletions.
2 changes: 1 addition & 1 deletion spid_cie_oidc/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.4.0"
__version__ = "1.4.1"
13 changes: 8 additions & 5 deletions spid_cie_oidc/authority/tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
INTERMEDIARY_JWK1 = serialize_rsa_key(INTERMEDIARY_RSA.priv_key, kind='private')
INTERMEDIARY_JWK1_pub = serialize_rsa_key(INTERMEDIARY_RSA.pub_key)

RP_METADATA_JWK1 = {'kty': 'RSA', 'n': 'w8H80eT2zrs2XQ-SApZG9TkuXDuIxANfCVHt4fFqNnOEZaCNWqlTQIo0JiSBE-QmzZ09TYP1BJpESuQf_PUeLRVPfYHsBVk5OYvhT27_nYlV7_1LsFGLxxsIa-hswMMzvW-1_huKLy6Fp0WP0ouUJAHsF_eYVtO1ApRhvlIVd5azM4k7t8Lh8lkCSdF1SfGHfXnXJRb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JiSBE-QmzZ09TYP1BJpESuQf_PUeLRVPfYHsBVk5OYvhT27_nYlV7_1LsFGLxxsIa-hswMMzvW-1_huKLy6Fp0WP0ouUJAHsF_eYVtO1ApRhvlIVd5azM4k7t8Lh8lkCSdF1SfGHfXnXJRb-XensZ0cFSfe2Koq9mD7jpGLXlPpXxj8Ow0g7KYT5kVtWE5ULmNmO7BIN1Hx4HpggbbEGgC9FyjKw4GfFb-csnB-icBPf_60HomjrkFFt6vTjrcqQaHOj-sEjP36N8rMSBiMmiMSPnsHhMQ', 'e': 'AQAB', 'kid': 'ENC-Km7n03ZqKDJfWVnlFudsW28YhQZx5eaXtAKA'}

rp_onboarding_data = dict(
name="RP Test",
Expand All @@ -20,7 +23,7 @@
rp_conf = {
"sub": rp_onboarding_data["sub"],
"jwks_fed" : [RP_METADATA_JWK1],
"jwks_core" : [RP_METADATA_JWK1],
"jwks_core" : [RP_METADATA_JWK1, RP_METADATA_JWK2],
"metadata": {
"openid_relying_party": {
"application_type": "web",
Expand All @@ -32,7 +35,7 @@
"response_types": ["code"],
"subject_type": "pairwise",
"client_id": "http://rp-test.it/oidc/rp/",
"jwks": {"keys": [RP_METADATA_JWK1_pub]},
"jwks": {"keys": [RP_METADATA_JWK1_pub, RP_METADATA_JWK2_pub]},
}
},
"authority_hints": ["http://testserver/"],
Expand All @@ -43,7 +46,7 @@
"iss": rp_conf["sub"],
"sub": rp_conf["sub"],
"jwks": {
"keys": [RP_METADATA_JWK1_pub]
"keys": [RP_METADATA_JWK1_pub, RP_METADATA_JWK2_pub]
},
"metadata": rp_conf["metadata"],
"authority_hints":rp_conf["authority_hints"]
Expand Down
13 changes: 8 additions & 5 deletions spid_cie_oidc/entity/tests/rp_metadata_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@
RP_METADATA_CIE_NOJWKS_NOJWKS_URI.pop("jwks_uri")


RP_METADATA_JWK1 = {'kty': 'RSA', 'n': 'w8H80eT2zrs2XQ-SApZG9TkuXDu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ZsCZJoc', 'kid': 'ENC-Km7n03ZqKDJfWVnlFudsW28YhQZx5eaXtAKA'}
RP_METADATA_JWK2_pub = {'alg': 'RSA-OAEP', 'use': 'enc', 'kty': 'RSA', 'n': 'w8H80eT2zrs2XQ-SApZG9TkuXDuIxANfCVHt4fFqNnOEZaCNWqlTQIo0JiSBE-QmzZ09TYP1BJpESuQf_PUeLRVPfYHsBVk5OYvhT27_nYlV7_1LsFGLxxsIa-hswMMzvW-1_huKLy6Fp0WP0ouUJAHsF_eYVtO1ApRhvlIVd5azM4k7t8Lh8lkCSdF1SfGHfXnXJRb-XensZ0cFSfe2Koq9mD7jpGLXlPpXxj8Ow0g7KYT5kVtWE5ULmNmO7BIN1Hx4HpggbbEGgC9FyjKw4GfFb-csnB-icBPf_60HomjrkFFt6vTjrcqQaHOj-sEjP36N8rMSBiMmiMSPnsHhMQ', 'e': 'AQAB', 'kid': 'ENC-Km7n03ZqKDJfWVnlFudsW28YhQZx5eaXtAKA'}

rp_onboarding_data = dict(
name="RP Test",
Expand All @@ -64,7 +67,7 @@
rp_conf = {
"sub": rp_onboarding_data["sub"],
"jwks_fed" : [RP_METADATA_JWK1],
"jwks_core" : [RP_METADATA_JWK1],
"jwks_core" : [RP_METADATA_JWK1, RP_METADATA_JWK2],
"metadata": {
"openid_relying_party": {
"application_type": "web",
Expand All @@ -76,7 +79,7 @@
"response_types": ["code"],
"subject_type": "pairwise",
"client_id": "http://rp-test.it/oidc/rp/",
"jwks": {"keys": [RP_METADATA_JWK1_pub]},
"jwks": {"keys": [RP_METADATA_JWK1_pub, RP_METADATA_JWK2_pub]},
}
},
"authority_hints": ["http://testserver/"],
Expand All @@ -87,7 +90,7 @@
"iss": rp_conf["sub"],
"sub": rp_conf["sub"],
"jwks": {
"keys": [RP_METADATA_JWK1_pub]
"keys": [RP_METADATA_JWK1_pub, RP_METADATA_JWK2_pub]
},
"metadata": rp_conf["metadata"],
"authority_hints":rp_conf["authority_hints"]
Expand Down
12 changes: 5 additions & 7 deletions spid_cie_oidc/entity/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@
logger = logging.getLogger(__name__)


def get_key(jwks, used=KeyUsage.signature):
# TODO change tests accordingly due 2 core keys
if len(jwks) > 1:
for jwk in jwks:
if jwk['use'] == used:
return jwk
return jwks[0]
def get_key(jwks, use=KeyUsage.signature):
for jwk in jwks:
if jwk['use'] == use:
return jwk
return jwks[0]


def iat_now() -> int:
Expand Down
2 changes: 2 additions & 0 deletions spid_cie_oidc/provider/tests/settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
op_conf_priv_jwk = {
"use": "sig",
"kty": "RSA",
"kid": "dB67gL7ck3TFiIAf7N6_7SHvqk0MDYMEQcoGGlkUAAw",
"n": "01_4aI2Lu5ggsElmRkE_S_a83V_szXU0txV4db2hmJ8HR1Y2s7PsZZ5-emGpnTydGrR3n-QExeEEIcFt_a06Ryiink34RQcKoGXUDBMBU0Bu8G7NcZ99YX6yeG9wFi4xs-WviTPmtPqijkz6jm1_ltWDcwbktfkraIRKKggZaEl9ldtsFr2wSpin3AXuGIdeJ0hZqhF92ODBLGjJlaIL9KlwopDy56adReVnraawSdrxmuPGj78IEADNAme2nQNvv9UCu0FkAn5St1bKds3Gpv26W0kjr1gZLsmQrj9lTcDk_KbAwfEY__P7se62kusoSuKMTQqUG1TQpUY7oFGSdw",
Expand Down Expand Up @@ -59,6 +60,7 @@
"jwks": {
"keys": [
{
"use": "sig",
"kty": "RSA",
"n": "01_4aI2Lu5ggsElmRkE_S_a83V_szXU0txV4db2hmJ8HR1Y2s7PsZZ5-emGpnTydGrR3n-QExeEEIcFt_a06Ryiink34RQcKoGXUDBMBU0Bu8G7NcZ99YX6yeG9wFi4xs-WviTPmtPqijkz6jm1_ltWDcwbktfkraIRKKggZaEl9ldtsFr2wSpin3AXuGIdeJ0hZqhF92ODBLGjJlaIL9KlwopDy56adReVnraawSdrxmuPGj78IEADNAme2nQNvv9UCu0FkAn5St1bKds3Gpv26W0kjr1gZLsmQrj9lTcDk_KbAwfEY__P7se62kusoSuKMTQqUG1TQpUY7oFGSdw",
"e": "AQAB",
Expand Down
6 changes: 4 additions & 2 deletions spid_cie_oidc/relying_party/tests/mocked_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from spid_cie_oidc.provider.tests.settings import op_conf, op_conf_priv_jwk
from spid_cie_oidc.authority.tests.settings import rp_conf, INTERMEDIARY_JWK1
from spid_cie_oidc.entity.jwtse import create_jws, create_jwe
from spid_cie_oidc.entity.utils import iat_now, exp_from_now
from spid_cie_oidc.entity.utils import iat_now, exp_from_now, get_key, KeyUsage
from spid_cie_oidc.entity.utils import get_jwks
from cryptojwt.jws.utils import left_hash
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -196,9 +196,11 @@ def content(self):
"https://attributes.eid.gov.it/fiscal_number": "sdfsfs908df09s8df90s8fd0"
}
jws = create_jws(jwt, op_conf_priv_jwk)
jwks = get_jwks(rp_conf["metadata"]["openid_relying_party"])
key = get_key(jwks, KeyUsage.encryption)
jwe = create_jwe(
jws,
get_jwks(rp_conf["metadata"]["openid_relying_party"])[0]
key
)
return jwe.encode()

Expand Down
1 change: 1 addition & 0 deletions spid_cie_oidc/relying_party/tests/test_04_rp_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
class RpCallBack(TestCase):
def setUp(self):
self.rp_jwk = {
'use': 'sig',
'kty': 'RSA',
'kid': '19xSsWuFOo5bFBUECA5G3V5GEhC0s7X8TTCEykdzsmo',
'e': 'AQAB',
Expand Down

0 comments on commit 9d86451

Please sign in to comment.