feat(auth): bootstrap token entries carry an optional scope

This commit is contained in:
hh
2026-08-30 18:25:48 +02:00
parent 064d855382
commit e90963a6c3
3 changed files with 54 additions and 20 deletions
+13
View File
@@ -44,3 +44,16 @@ async def test_missing_everything_is_401(runtime) -> None:
with pytest.raises(HTTPException) as exc:
await require_token(_request(), runtime, scope="api")
assert exc.value.status_code == 401
async def test_bootstrap_entry_can_carry_a_scope() -> None:
raw = "admin:secret-a,komodo:hook-value:api"
store = TokenStore(
bootstrap=TokenStore.parse_bootstrap(raw),
bootstrap_scopes=TokenStore.parse_bootstrap_scopes(raw),
)
admin = await store.verify("secret-a")
hook = await store.verify("hook-value")
assert admin is not None and admin.scope == "*"
assert hook is not None and hook.scope == "api" and hook.name == "komodo"
assert not hook.allows("admin") and hook.allows("api")