gunk-dev/the-valley

identity-schema.sh

source2dbaec32c6e9main's published tip history
1.7 KiB
1# shellcheck shell=bash
2# Paths and fixtures come from the derivation environment.
3# shellcheck disable=SC2154
4cue vet -c "$schema" "$registry"/*.cue
5cue export "$schema" "$registry"/*.cue > registry.json
6grep -q '"genesis": "operator"' registry.json
7# The signing name is per key, not per entry: one entry holds keys signing
8# under two different names, and that is what the compiler renders from.
9grep -q '"signs": "workstation/attestations"' registry.json
10grep -q '"signs": "operator"' registry.json
11# The read grants: an edge read boundary at example.org, which the
12# operator reads every project at and anyone reads app at, by its identity.
13[ "$(cue export -e boundaries.web.destination "$schema" "$registry"/*.cue)" = '"example.org"' ]
14[ "$(cue export -e principals.operator.grants.read.projects "$schema" "$registry"/*.cue)" = '"all"' ]
15[ "$(cue export -e anyone.grants.read.projects.app "$schema" "$registry"/*.cue)" \
16 = '"9da6809f038df92138c131cd16bed76d"' ]
17
18# The registries the schema must reject, and the words each rejection must
19# name. The floor's properties are here — mandatory expiry where a raw key
20# is held, no external principal governing the registry, a genesis entry
21# that governs it — and a rejection that stopped naming its field would be a
22# floor nobody can act on.
23while IFS=$'\t' read -r name names; do
24 case "$name" in '' | '#'*) continue ;; esac
25 if cue vet -c "$schema" "$rejected/$name.cue" > "$name.err" 2>&1; then
26 echo "identity-schema: expected invalid registry '$name' to be rejected" >&2
27 exit 1
28 fi
29 if [ -n "$names" ] && ! grep -qF -- "$names" "$name.err"; then
30 echo "identity-schema: '$name' was rejected without naming $names" >&2
31 cat "$name.err" >&2
32 exit 1
33 fi
34done < "$rejectedCases"
35touch "$out"