fix(auth): authenticate producer-signed decisions before authorization
Assistant: codex Assistant-Model: gpt-6-astra Assistant-Session: 01a140c4-354a-7823-8f0d-8f717397f786
This commit is contained in:
parent
6bd7129eac
commit
c80a944105
30 changed files with 2059 additions and 32 deletions
35
tests/signature_support.py
Normal file
35
tests/signature_support.py
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
"""Native producer signing fixtures, never an authentication bypass."""
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import pytest
|
||||
|
||||
PUBLIC='IVL40Zt5HSRFMkLhXy6rbLfP-ntqXtMAl5YOBpiB2xI'
|
||||
|
||||
@pytest.fixture(scope='session')
|
||||
def signature_tools(tmp_path_factory):
|
||||
directory=tmp_path_factory.mktemp('signature-tools')
|
||||
# Private writable build cache keeps tests runnable in the workspace sandbox.
|
||||
env={**os.environ,'GOCACHE':os.environ.get('GOCACHE',str(directory/'cache'))}
|
||||
root=Path(__file__).parents[1]/'verifier'
|
||||
for name,package in [('verify','.'),('sign','./testsupport/signer')]:
|
||||
subprocess.run(['go','build','-o',str(directory/name),package],cwd=root,env=env,check=True,timeout=120)
|
||||
return directory
|
||||
|
||||
|
||||
def admit_tools(cfg, directory, tools):
|
||||
trust={'schema':'secrets-engine.pdp-trust.v1','evaluator':'stub/local','mode':'standalone',
|
||||
'policy_package':cfg.authorization_policy_package,'policy_version':cfg.authorization_policy_version,
|
||||
'policy_package_digest':'sha256:'+'1'*64,'keys':{'testdata-ed25519':PUBLIC}}
|
||||
path=directory/'pdp-trust.json';path.write_text(json.dumps(trust))
|
||||
from dataclasses import is_dataclass, replace
|
||||
if is_dataclass(cfg):
|
||||
return replace(cfg,pdp_trust_file=path,pdp_verifier=tools/'verify')
|
||||
cfg.pdp_trust_file=path;cfg.pdp_verifier=tools/'verify'
|
||||
return cfg
|
||||
|
||||
|
||||
def sign_envelope(envelope,tools,next_key=False):
|
||||
result=subprocess.run([str(tools/'sign')]+(['next'] if next_key else []),input=json.dumps(envelope),text=True,capture_output=True,check=True,timeout=3)
|
||||
return json.loads(result.stdout)
|
||||
Loading…
Add table
Add a link
Reference in a new issue