Take the portal's JWKS from the tunnel and verify by kid
The welcome frame's keys replace the set pinned at enrolment, but only over wss:// or loopback, the rule enrolment applies to the portal address. Portal tokens are verified against the key their kid names, so the hub can publish a new key beside the old one. A welcome without keys, from an older hub, leaves the pinned set alone.
This commit is contained in:
@@ -38,7 +38,7 @@ class EnrollError(Exception):
|
||||
self.detail = detail
|
||||
|
||||
|
||||
def _is_loopback(url: str) -> bool:
|
||||
def is_loopback(url: str) -> bool:
|
||||
"""Whether the address is this machine.
|
||||
|
||||
Not a `*.local` name: mDNS answers it with whoever claims it on the LAN,
|
||||
@@ -62,7 +62,7 @@ def redeem_claim(
|
||||
# this address. Over plain http both are readable by anything on the path,
|
||||
# so refuse rather than enrol insecurely — bar a loopback portal, which is
|
||||
# how the stack is developed against itself.
|
||||
if not base.startswith("https://") and not _is_loopback(base):
|
||||
if not base.startswith("https://") and not is_loopback(base):
|
||||
raise EnrollError(422, "The portal address must be https:// (or this machine)")
|
||||
try:
|
||||
response = httpx.post(
|
||||
@@ -110,7 +110,7 @@ def enroll(
|
||||
token=data["instance_token"],
|
||||
issuer=data["issuer"],
|
||||
# Pinned here, at the one moment the claim code proves who we are
|
||||
# talking to. Nothing refreshes this.
|
||||
# talking to. The tunnel refreshes it on every attach after this.
|
||||
jwks=data["jwks"],
|
||||
local_user_id=str(user.id),
|
||||
enrolled_at=datetime.now(UTC).isoformat(),
|
||||
|
||||
Reference in New Issue
Block a user