Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2887,7 +2887,25 @@ jobs:
run: uv run --no-project --with PyYAML==6.0.2 python3 -m unittest release/scripts/test_check_gates_inventory.py

- name: Validate release manifest
run: uv run --no-project --with PyYAML==6.0.2 python3 release/scripts/registry-release validate-current
env:
RELEASE_MANIFEST_BASE_REF: ${{ needs.changes.outputs.archive_base_ref }}
RELEASE_MANIFEST_COMPARISON_REQUIRED: ${{ needs.changes.outputs.archive_comparison_required }}
shell: bash
run: |
set -euo pipefail
validate=(uv run --no-project --with PyYAML==6.0.2 python3 release/scripts/registry-release validate-current-ci)
if [[ "${RELEASE_MANIFEST_COMPARISON_REQUIRED}" == "true" ]]; then
if [[ -z "${RELEASE_MANIFEST_BASE_REF}" ]]; then
echo "Cannot validate the inherited release manifest: the event baseline is unavailable." >&2
exit 1
fi
"${validate[@]}" --base-ref "${RELEASE_MANIFEST_BASE_REF}"
elif [[ "${RELEASE_MANIFEST_COMPARISON_REQUIRED}" == "false" ]]; then
"${validate[@]}"
else
echo "The release manifest comparison policy is unavailable." >&2
exit 1
fi

- name: Validate release docsets
run: uv run --no-project --with PyYAML==6.0.2 python3 release/scripts/registry-release validate-docsets
Expand Down
10 changes: 5 additions & 5 deletions clients/typescript/generated/casework.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Generated for Stack version 0.52.0, client version 0.52.0.
// Source SHA-256 095bdd1b45a0e8031bb3d6cff6b2223514c250f14c985ca177abe6f8d18d9277
// Source SHA-256 843ccf26e5f9831d52416305c075e822607128bb505a5b34bbdd0dc6f7976928
// Unconstrained JSON /components/schemas/ReviewHistoryEntry/properties/detail
// Unconstrained JSON /components/schemas/ReviewPolicy/properties/displaySchema
// Unconstrained JSON /components/schemas/ReviewPolicy/properties/resultSchema
Expand Down Expand Up @@ -53,7 +53,7 @@ export type Schema_InputDecisionKind = (({ "outcome": (string); "publicReason"?:
export type Schema_InputDirectoryMember = ({ "displayName"?: (string | null); "issuer": (string); "subject": (string) })
export type Schema_InputDirectoryTargetPurpose = ("assignment" | "absence-person" | "absence-cover") & (string)
export type Schema_InputHolidaySetDocument = ({ "dates": (Array<(string)>); "holidaySet": (string); "revision": (number) })
export type Schema_InputHumanIdentity = ({ "issuer": (string); "subject": (string) })
export type Schema_InputHumanIdentity = ({ "issuer": (string); "principalClaim": (string); "subject": (string) })
export type Schema_InputIssuerPrincipal = ({ "issuer": (string); "subject": (string) })
export type Schema_InputPolicySelection = ({ "digest"?: Schema_InputContentDigest; "id": (string); "version"?: (string) })
export type Schema_InputReviewAskWant = (({ "kind": "answer" & (string) }) | ({ "kind": "document" & (string) }))
Expand Down Expand Up @@ -172,7 +172,7 @@ export type Schema_ReviewPolicyClosure = ({ "clocks"?: (Array<(string)>); "conte
export type Schema_ReviewPolicyClosureList = (Array<Schema_ReviewPolicyClosure>)
export type Schema_ReviewPolicyDependencies = ({ "accessProfiles": (Array<Schema_AccessProfile>); "calendars": (Array<Schema_CalendarPolicy>); "clocks": (Array<Schema_ClockPolicy>); "contextProvider": (Schema_ReviewContextProviderPolicy | (null)); "inbox": Schema_InboxPolicy; "queues": (Array<Schema_QueuePolicy>); "taskTemplates": (Array<Schema_TaskTemplate>); "teams": (Array<Schema_TeamPolicy>); "trustedProducers": (Array<Schema_ReviewProducerPolicy>) })
export type Schema_ReviewPolicyIdentity = ({ "digest": Schema_Digest; "id": Schema_LocalId; "version": (string) })
export type Schema_ReviewProducerPolicy = ({ "completion"?: (Schema_ReviewCompletionDestinationPolicy | (null)); "id": Schema_LocalId; "initiatorProfile"?: (string | null); "issuer": Schema_Url; "profile": (string); "readsAsks"?: (boolean); "retention": Schema_ProducerRetention; "reviewPolicies": (Array<(string)>); "sourceNamespaces": (Array<(string)>); "subject": (string); "trustedInitiatorIssuer"?: Schema_Url })
export type Schema_ReviewProducerPolicy = ({ "completion"?: (Schema_ReviewCompletionDestinationPolicy | (null)); "id": Schema_LocalId; "initiatorProfile"?: (string | null); "issuer": Schema_Url; "profile": (string); "readsAsks"?: (boolean); "retention": Schema_ProducerRetention; "reviewPolicies": (Array<(string)>); "sourceNamespaces": (Array<(string)>); "subject": (string); "trustedInitiatorIssuer"?: Schema_Url; "trustedInitiatorPrincipalClaim"?: (string | null) })
export type Schema_ReviewProgressCode = (string)
export type Schema_ReviewPublicReasonRule = ("required" | "optional" | "none") & (string)
export type Schema_ReviewPurpose = ("approval" | "answer") & (string)
Expand Down Expand Up @@ -334,7 +334,7 @@ const rules: Record<string, unknown> = Object.fromEntries([
["/components/schemas/InputDirectoryMember", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"displayName\":{\"type\":[\"string\",\"null\"]},\"issuer\":{\"type\":\"string\"},\"subject\":{\"type\":\"string\"}},\"required\":[\"issuer\",\"subject\"],\"type\":\"object\"}")],
["/components/schemas/InputDirectoryTargetPurpose", JSON.parse("{\"enum\":[\"assignment\",\"absence-person\",\"absence-cover\"],\"type\":\"string\"}")],
["/components/schemas/InputHolidaySetDocument", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"dates\":{\"items\":{\"type\":\"string\"},\"type\":\"array\"},\"holidaySet\":{\"type\":\"string\"},\"revision\":{\"minimum\":0,\"type\":\"integer\"}},\"required\":[\"holidaySet\",\"revision\",\"dates\"],\"type\":\"object\"}")],
["/components/schemas/InputHumanIdentity", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"issuer\":{\"type\":\"string\"},\"subject\":{\"type\":\"string\"}},\"required\":[\"issuer\",\"subject\"],\"type\":\"object\"}")],
["/components/schemas/InputHumanIdentity", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"issuer\":{\"type\":\"string\"},\"principalClaim\":{\"type\":\"string\"},\"subject\":{\"type\":\"string\"}},\"required\":[\"issuer\",\"principalClaim\",\"subject\"],\"type\":\"object\"}")],
["/components/schemas/InputIssuerPrincipal", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"issuer\":{\"type\":\"string\"},\"subject\":{\"type\":\"string\"}},\"required\":[\"issuer\",\"subject\"],\"type\":\"object\"}")],
["/components/schemas/InputPolicySelection", JSON.parse("{\"additionalProperties\":false,\"dependentRequired\":{\"digest\":[\"version\"],\"version\":[\"digest\"]},\"properties\":{\"digest\":{\"$ref\":\"/components/schemas/InputContentDigest\"},\"id\":{\"type\":\"string\"},\"version\":{\"type\":\"string\"}},\"required\":[\"id\"],\"type\":\"object\"}")],
["/components/schemas/InputReviewAskWant", JSON.parse("{\"oneOf\":[{\"additionalProperties\":false,\"properties\":{\"kind\":{\"const\":\"answer\",\"type\":\"string\"}},\"required\":[\"kind\"],\"type\":\"object\"},{\"additionalProperties\":false,\"properties\":{\"kind\":{\"const\":\"document\",\"type\":\"string\"}},\"required\":[\"kind\"],\"type\":\"object\"}]}")],
Expand Down Expand Up @@ -449,7 +449,7 @@ const rules: Record<string, unknown> = Object.fromEntries([
["/components/schemas/ReviewPolicyClosureList", JSON.parse("{\"items\":{\"$ref\":\"/components/schemas/ReviewPolicyClosure\"},\"type\":\"array\"}")],
["/components/schemas/ReviewPolicyDependencies", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"accessProfiles\":{\"items\":{\"$ref\":\"/components/schemas/AccessProfile\"},\"type\":\"array\"},\"calendars\":{\"items\":{\"$ref\":\"/components/schemas/CalendarPolicy\"},\"type\":\"array\"},\"clocks\":{\"items\":{\"$ref\":\"/components/schemas/ClockPolicy\"},\"type\":\"array\"},\"contextProvider\":{\"anyOf\":[{\"$ref\":\"/components/schemas/ReviewContextProviderPolicy\"},{\"type\":\"null\"}]},\"inbox\":{\"$ref\":\"/components/schemas/InboxPolicy\"},\"queues\":{\"items\":{\"$ref\":\"/components/schemas/QueuePolicy\"},\"type\":\"array\"},\"taskTemplates\":{\"items\":{\"$ref\":\"/components/schemas/TaskTemplate\"},\"type\":\"array\"},\"teams\":{\"items\":{\"$ref\":\"/components/schemas/TeamPolicy\"},\"type\":\"array\"},\"trustedProducers\":{\"items\":{\"$ref\":\"/components/schemas/ReviewProducerPolicy\"},\"type\":\"array\"}},\"required\":[\"accessProfiles\",\"queues\",\"teams\",\"clocks\",\"calendars\",\"contextProvider\",\"taskTemplates\",\"trustedProducers\",\"inbox\"],\"type\":\"object\"}")],
["/components/schemas/ReviewPolicyIdentity", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"digest\":{\"$ref\":\"/components/schemas/Digest\"},\"id\":{\"$ref\":\"/components/schemas/LocalId\"},\"version\":{\"type\":\"string\"}},\"required\":[\"id\",\"version\",\"digest\"],\"type\":\"object\"}")],
["/components/schemas/ReviewProducerPolicy", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"completion\":{\"anyOf\":[{\"$ref\":\"/components/schemas/ReviewCompletionDestinationPolicy\"},{\"type\":\"null\"}]},\"id\":{\"$ref\":\"/components/schemas/LocalId\"},\"initiatorProfile\":{\"type\":[\"string\",\"null\"]},\"issuer\":{\"$ref\":\"/components/schemas/Url\"},\"profile\":{\"type\":\"string\"},\"readsAsks\":{\"type\":\"boolean\"},\"retention\":{\"$ref\":\"/components/schemas/ProducerRetention\"},\"reviewPolicies\":{\"items\":{\"type\":\"string\"},\"type\":\"array\"},\"sourceNamespaces\":{\"items\":{\"type\":\"string\"},\"type\":\"array\"},\"subject\":{\"type\":\"string\"},\"trustedInitiatorIssuer\":{\"$ref\":\"/components/schemas/Url\"}},\"required\":[\"id\",\"profile\",\"issuer\",\"subject\",\"sourceNamespaces\",\"reviewPolicies\",\"retention\"],\"type\":\"object\"}")],
["/components/schemas/ReviewProducerPolicy", JSON.parse("{\"additionalProperties\":false,\"properties\":{\"completion\":{\"anyOf\":[{\"$ref\":\"/components/schemas/ReviewCompletionDestinationPolicy\"},{\"type\":\"null\"}]},\"id\":{\"$ref\":\"/components/schemas/LocalId\"},\"initiatorProfile\":{\"type\":[\"string\",\"null\"]},\"issuer\":{\"$ref\":\"/components/schemas/Url\"},\"profile\":{\"type\":\"string\"},\"readsAsks\":{\"type\":\"boolean\"},\"retention\":{\"$ref\":\"/components/schemas/ProducerRetention\"},\"reviewPolicies\":{\"items\":{\"type\":\"string\"},\"type\":\"array\"},\"sourceNamespaces\":{\"items\":{\"type\":\"string\"},\"type\":\"array\"},\"subject\":{\"type\":\"string\"},\"trustedInitiatorIssuer\":{\"$ref\":\"/components/schemas/Url\"},\"trustedInitiatorPrincipalClaim\":{\"type\":[\"string\",\"null\"]}},\"required\":[\"id\",\"profile\",\"issuer\",\"subject\",\"sourceNamespaces\",\"reviewPolicies\",\"retention\"],\"type\":\"object\"}")],
["/components/schemas/ReviewProgressCode", JSON.parse("{\"maxLength\":64,\"minLength\":1,\"pattern\":\"^[a-z][a-z0-9_-]{0,63}$\",\"type\":\"string\"}")],
["/components/schemas/ReviewPublicReasonRule", JSON.parse("{\"enum\":[\"required\",\"optional\",\"none\"],\"type\":\"string\"}")],
["/components/schemas/ReviewPurpose", JSON.parse("{\"enum\":[\"approval\",\"answer\"],\"type\":\"string\"}")],
Expand Down
1 change: 1 addition & 0 deletions crates/registry-breg/src/api/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,7 @@ mod tests {
fn authenticated_context_preserves_identity_values_larger_than_review_protocol_bounds() {
let identity = registry_review_client::HumanIdentity {
issuer: format!("https://identity.example/{}", "i".repeat(300)),
principal_claim: "sub".to_owned(),
subject: "s".repeat(300),
};
let claims = VerifiedRequestClaims::authenticated(
Expand Down
96 changes: 96 additions & 0 deletions crates/registry-breg/src/api/tests/immediate_action_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use registry_platform_httputil::FetchUrlPolicy;
use registry_platform_oidc::{ClaimNames, JwksFetcher, JwksFetcherConfig};
use registry_platform_testing::{oidc_verifier_config, MockIdp};
use std::time::{Duration, Instant};
use tower::ServiceExt;
use zeroize::Zeroizing;

const PROJECT: &str = r#"
Expand Down Expand Up @@ -99,6 +100,101 @@ fn compiled() -> Arc<CompiledRegistry> {
)
}

#[tokio::test]
async fn internal_hook_profile_is_excluded_from_action_invoke_http_authority() {
let mut project = parse_project_yaml(PROJECT.as_bytes()).expect("action fixture parses");
project.entities[0].hooks.push(
serde_json::from_value(json!({
"id": "case-created",
"phase": "after",
"trigger": "created",
"principal": "hook-worker",
"projection": ["label"],
"handler": {"type": "url", "destinationId": "case-events"}
}))
.expect("hook declaration parses"),
);
project.access_profiles.push(
serde_json::from_value(json!({
"id": "hook-worker",
"principalClaim": "registry_principal",
"requiredScopes": "unrestricted",
"permissions": {"actions": [{
"action": "rename-case",
"operations": ["invoke"],
"targets": [{"recordType": "case", "rowBoundaries": "unrestricted"}],
"results": ["renamed"]
}]}
}))
.expect("hook profile parses"),
);
let registry = Arc::new(
compile_project(&project, &[], CompileProfile::Authoring).expect("hook project compiles"),
);
let service = Arc::new(service_for(Arc::clone(&registry), true));
let route = registry
.actions()
.routes
.iter()
.find(|route| route.kind == ActionRouteKind::Invoke)
.expect("Invoke route compiles");
let idp = MockIdp::start().await;
let audience = "urn:example:breg";
let mut verifier = oidc_verifier_config(idp.issuer(), vec![audience.to_owned()]);
verifier.allowed_clients = vec!["agent-client".to_owned()];
let authenticator = Arc::new(
RegistryAuthenticator::new(
&registry,
verifier,
Arc::new(JwksFetcher::new_with_fetch_url_policy(
idp.jwks_uri(),
JwksFetcherConfig::defaults(),
FetchUrlPolicy::https_or_loopback(),
)),
AuthorityClaimConfig::new("registry_principal", Some("registry_purpose".to_owned())),
)
.expect("omitted issuer profile list is valid"),
);
let app = crate::api::authenticated_router(service, authenticator);
let send = |token: String, profile: &str| {
let request = axum::http::Request::builder()
.method("POST")
.uri(format!("{}?accessProfile={profile}", route.path))
.header(axum::http::header::AUTHORIZATION, format!("Bearer {token}"))
.body(Body::empty())
.expect("Action request builds");
app.clone().oneshot(request)
};

let ordinary = idp.mint_token(json!({
"aud": audience,
"sub": "ordinary-registrar",
"azp": "agent-client",
"registry_principal": "ordinary-registrar",
"registry_purpose": "case-management",
"regions": ["north"],
"scope": "case.rename"
}));
// An admitted caller reaches input validation before any mutation.
let admitted = send(ordinary, "registrar").await.expect("router responds");
assert_eq!(admitted.status(), StatusCode::UNSUPPORTED_MEDIA_TYPE);

let hook = idp.mint_token(json!({
"aud": audience,
"sub": "hook-caller",
"azp": "agent-client",
"registry_principal": "hook-caller",
"scope": "hook.invoke"
}));
let denied = send(hook, "hook-worker").await.expect("router responds");
assert_eq!(denied.status(), StatusCode::FORBIDDEN);
let body = to_bytes(denied.into_body(), 4096)
.await
.expect("read refusal");
let problem: Value = serde_json::from_slice(&body).expect("problem response");
assert_eq!(problem["code"], "profile.not-authorized");
}

fn task_action_registry() -> Arc<CompiledRegistry> {
let mut project = parse_project_yaml(PROJECT.as_bytes()).unwrap();
project.access_profiles.push(serde_json::from_value(json!({
Expand Down
35 changes: 35 additions & 0 deletions crates/registry-breg/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ pub enum AuthenticationConfigError {
ConflictingClaimExpectation,
#[error("an issuer entry names an access profile that the compiled registry does not declare")]
UnknownAccessProfile,
#[error(
"an issuer entry explicitly reaches a proposing Record hook's internal access profile"
)]
HookProfileHttpReachable,
#[error("an access profile that reads the principal or names requester clients is reachable from more than one issuer entry")]
PrincipalAcrossIssuers,
}
Expand Down Expand Up @@ -412,6 +416,18 @@ pub(crate) fn compiled_profile_facts(
facts
}

/// Access profiles selected by governed Record hooks that may return Action
/// proposals. They are internal worker authority and are never HTTP caller
/// profiles, even when an issuer entry omits its `accessProfiles` list.
pub fn proposing_hook_profiles(registry: &CompiledRegistry) -> BTreeSet<String> {
registry
.event_deliveries()
.deliveries
.iter()
.filter_map(|delivery| delivery.principal.clone())
.collect()
}

/// Production OIDC verifiers plus the only claim mapping allowed to construct
/// [`VerifiedRequestClaims`].
pub struct RegistryAuthenticator {
Expand Down Expand Up @@ -471,15 +487,22 @@ impl RegistryAuthenticator {
.collect::<Vec<_>>();
let direct_claims = validate_claim_mapping(registry, &profiles, &claims)?;
let profile_facts = compiled_profile_facts(registry);
let hook_profiles = proposing_hook_profiles(registry);
for issuer in &issuers {
if let Some(listed) = &issuer.access_profiles {
if listed.is_empty() || listed.iter().any(|id| !profile_facts.contains_key(id)) {
return Err(AuthenticationConfigError::UnknownAccessProfile);
}
if listed.iter().any(|id| hook_profiles.contains(id)) {
return Err(AuthenticationConfigError::HookProfileHttpReachable);
}
}
}
if issuers.len() > 1 {
for (profile_id, facts) in &profile_facts {
if hook_profiles.contains(profile_id) {
continue;
}
if !facts.reads_principal && !facts.has_requester_clients {
continue;
}
Expand Down Expand Up @@ -510,6 +533,17 @@ impl RegistryAuthenticator {
declared,
access_profiles,
} = issuer;
let access_profiles = if hook_profiles.is_empty() || access_profiles.is_some() {
access_profiles
} else {
Some(
profile_facts
.keys()
.filter(|profile_id| !hook_profiles.contains(*profile_id))
.cloned()
.collect(),
)
};
let namespace = several.then(|| verifier.issuer.clone());
let repeated = rules
.insert(
Expand Down Expand Up @@ -736,6 +770,7 @@ impl RegistryAuthenticator {
let human_identity = if actor_kind == Some(registry_platform_oidc::ActorKind::Human) {
Some(registry_review_client::HumanIdentity {
issuer: rules.issuer.clone(),
principal_claim: self.principal_claim.clone(),
subject: principal.clone(),
})
} else {
Expand Down
Loading
Loading