Skip to content

Commit 7a97a49

Browse files
committed
docs: registration policies: x509 subject validation
Asciinema: https://asciinema.org/a/627198 Signed-off-by: John Andersen <[email protected]>
1 parent 381bb35 commit 7a97a49

File tree

4 files changed

+51
-12
lines changed

4 files changed

+51
-12
lines changed

docs/registration_policies.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,42 @@ Simple drop rule based on claim content allowlist.
6666
{
6767
"$id": "https://schema.example.com/scitt-allowlist.schema.json",
6868
"$schema": "https://json-schema.org/draft/2020-12/schema",
69+
"required": ["issuer", "issuer_key"],
6970
"properties": {
7071
"issuer": {
7172
"type": "string",
7273
"enum": [
7374
"did:web:example.org"
7475
]
76+
},
77+
"issuer_key": {
78+
"type": "object",
79+
"required": ["content_type", "certificate"],
80+
"properties": {
81+
"content_type": {
82+
"type": "string",
83+
"enum": [
84+
"application/pkix-cert"
85+
]
86+
},
87+
"certificate": {
88+
"type": "object",
89+
"required": ["subject"],
90+
"properties": {
91+
"subject": {
92+
"type": "object",
93+
"properties": {
94+
"O": {
95+
"type": "string",
96+
"enum": [
97+
"SCITT Emulator"
98+
]
99+
}
100+
}
101+
}
102+
}
103+
}
104+
}
75105
}
76106
}
77107
}

scitt_emulator/key_loader_format_url_referencing_oidc_issuer.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ def to_object_oidc_issuer(verification_key: VerificationKey) -> dict:
7979
return
8080

8181
return {
82-
**verification_key.original.export_public(as_dict=True),
83-
"use": "sig",
84-
"kid": verification_key.original.thumbprint(),
82+
"content_type": verification_key.original_content_type,
83+
"key": {
84+
**verification_key.original.export_public(as_dict=True),
85+
"use": "sig",
86+
"kid": verification_key.original.thumbprint(),
87+
},
8588
}

scitt_emulator/key_loader_format_url_referencing_x509.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,10 @@ def key_loader_format_url_referencing_x509(
4040
for certificate in cryptography.x509.load_pem_x509_certificates(
4141
contents
4242
):
43-
key = certificate.public_key()
4443
keys.append(
4544
VerificationKey(
46-
transforms=[key],
47-
original=key,
45+
transforms=[certificate, certificate.public_key()],
46+
original=certificate,
4847
original_content_type=CONTENT_TYPE,
4948
original_bytes=contents,
5049
original_bytes_encoding="utf-8",
@@ -60,8 +59,12 @@ def key_loader_format_url_referencing_x509(
6059
def to_object_x509(verification_key: VerificationKey) -> dict:
6160
if verification_key.original_content_type != CONTENT_TYPE:
6261
return
63-
64-
# TODO to dict
65-
verification_key.original
66-
67-
return {}
62+
return {
63+
"content_type": verification_key.original_content_type,
64+
"certificate": {
65+
"subject": {
66+
attribute.rfc4514_attribute_name: attribute.value
67+
for attribute in verification_key.original.subject
68+
},
69+
},
70+
}

tests/test_cli.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def ssh_public_keys():
211211
io.BytesIO(cert_pem),
212212
mimetype="text/plain",
213213
)
214-
# TODO Re-enable
214+
# TODO Re-enable ssh authorized_keys
215215
return send_file(
216216
io.BytesIO(
217217
serialization.load_pem_public_key(
@@ -224,6 +224,9 @@ def ssh_public_keys():
224224
mimetype="text/plain",
225225
)
226226

227+
# TODO Re-enable oidc/jwks
228+
return app
229+
227230
@app.route("/.well-known/openid-configuration", methods=["GET"])
228231
def openid_configuration():
229232
return jsonify(

0 commit comments

Comments
 (0)