Skip to content

feat(storage): optionally add a principal to the STS session policy - #2139

Merged
brgr-s merged 4 commits into
lakekeeper:mainfrom
Mohil-Ahuja:fix/sts-session-policy-principal
Oct 22, 2026
Merged

brgr-s merged 4 commits into
lakekeeper:mainfrom
Mohil-Ahuja:fix/sts-session-policy-principal

Conversation

@Mohil-Ahuja

@Mohil-Ahuja Mohil-Ahuja commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1960.

Yandex Object Storage's STS rejects requests made with temporary credentials when the session policy's statements carry no Principal (MalformedPolicy: required field missed: principal should be specified), so sts-enabled profiles against it fail both the warehouse write-test and every vended-credentials read and write. The reporter confirmed that adding "Principal": "*" to each statement fixes it.

This can't be turned on for every s3-compat profile:

  • MinIO parses session policies with ParseConfig, which uses DisallowUnknownFields, and its IAM Statement has no Principal field, so it would start rejecting AssumeRole. minio is an alias of s3-compat here.
  • AWS treats a session policy as an identity-based policy, where Principal isn't allowed either.

So it's opt-in, as proposed in the issue.

Change

  • New S3 profile option sts-session-policy-principal (Option<bool>, default unset/false). When true, get_sts_policy_string adds "Principal": "*" to every statement of the generated session policy. It's an Option<bool> like allow-alternative-protocols, which also keeps S3Profile within clippy's struct_excessive_bools.
  • Docs: a row in the S3 profile table in storage-s3.md, noting Yandex needs it and AWS/MinIO reject it.
  • OpenAPI: the property is added to management-open-api.yaml (checked against the output of management-openapi) and mirrored in management-open-api-plus.yaml.

Tests

New unit tests in service::storage::s3:

  • the session policy has no Principal by default, and when the option is false
  • with the option true, every statement has "Principal": "*"
  • a profile JSON without the field deserializes to None

cargo test -p lakekeeper --lib policy passes (59), cargo clippy -p lakekeeper --all-targets -- -D warnings is clean, and rustfmt is clean on the changed files. I couldn't test against Yandex itself; the policy shape matches what the reporter verified there.

Summary by CodeRabbit

  • New Features

    • Added the optional sts-session-policy-principal setting for S3 profiles.
    • When enabled, generated STS session-policy statements include "Principal": "*".
    • When disabled or omitted, statements do not include a principal; the setting defaults to false.
    • Added the setting to S3 configuration and API documentation.
  • Bug Fixes

    • Added validation to reject this setting for AWS, Cloudflare R2, and Alibaba Cloud OSS profiles.

@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: aef5a08a-414b-499c-9d15-cc6853b2f555
📥 Commits

Reviewing files that changed from the base of the PR and between 9fbf21a and 2c8fe5a.

📒 Files selected for processing: 2
  • crates/lakekeeper/src/service/storage/s3.rs
  • docs/docs/storage-s3.md
🚧 Files skipped from review as they are similar to previous changes: 1
  • docs/docs/storage-s3.md

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

Walkthrough

An optional S3 profile setting controls whether generated STS session-policy statements include "Principal": "*". Validation restricts the setting by provider. API schemas, documentation, Stackit conversion, and tests cover the setting.

Changes

STS Policy Principal

Layer / File(s) Summary
Profile setting and schema
crates/lakekeeper/src/service/storage/s3.rs, crates/lakekeeper/src/service/storage/stackit.rs, docs/docs/api/management-open-api*.yaml, docs/docs/storage-s3.md
Adds the optional setting to S3Profile, initializes it to None in Stackit conversion, and documents its default and behavior.
Provider-specific validation
crates/lakekeeper/src/service/storage/s3.rs
Rejects the enabled setting for AWS, Cloudflare R2, and Alibaba Cloud OSS credentials. S3-compatible profiles remain accepted.
STS policy generation and tests
crates/lakekeeper/src/service/storage/s3.rs
When enabled, generated policy statements include "Principal": "*". Tests cover default omission, explicit values, deserialization, insertion, and provider validation.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature · Severity of issue fixed: Medium

Suggested reviewers: brgr-s

Merge Risk: ⚪ Minimal · up to 2c8fe

The opt-in setting has no identified issue requiring a change before merge. Normal checks remain appropriate.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 2 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: adding an optional principal to the STS session policy.
Linked Issues check Passed Issue [#1960] requires Yandex-compatible STS session policies with an explicit principal on each statement. get_sts_policy_string adds "Principal": "*" to every statement when `sts-session-policy-…
Out of Scope Changes check Passed The changes remain within issue [#1960]. The S3 option, policy generation, provider validation, tests, Stackit initialization, documentation, and OpenAPI schema updates support the Yandex STS compatib…
Full details: Linked Issues check

Explanation

Issue [#1960] requires Yandex-compatible STS session policies with an explicit principal on each statement. get_sts_policy_string adds "Principal": "*" to every statement when sts-session-policy-principal is enabled. The option remains unset by default, so AWS and MinIO behavior is preserved. Tests cover enabled, disabled, omitted-field, and provider-rejection cases. Documentation and both OpenAPI schemas expose the option and its restrictions.

Full details: Out of Scope Changes check

Explanation

The changes remain within issue [#1960]. The S3 option, policy generation, provider validation, tests, Stackit initialization, documentation, and OpenAPI schema updates support the Yandex STS compatibility behavior or preserve existing profiles. No unrelated change is demonstrated.

Full details: Docstring Coverage

Explanation

Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 2 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit hops through policies bright
With stars in statements, placed just right
AWS keeps its fields unchanged
Tests check each path, well arranged
Yandex’s policy now takes flight

Comment @coderabbitai help to get the list of available commands.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Oct 17, 2026
@brgr-s

brgr-s commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

@Mohil-Ahuja the main part LGTM, just one small nit: I think we should reject the flag in normalize for the Aliyun OSS and R2 path and flavor: aws

@Mohil-Ahuja

Copy link
Copy Markdown
Contributor Author

Thanks! Done in 29da962: normalize now rejects sts-session-policy-principal: true for the aws flavor and for Cloudflare R2 and Alibaba Cloud OSS credentials, with an InvalidProfileError on the sts-session-policy-principal entity. The check runs before the R2 and OSS normalization, since OSS forces the flavor to s3-compat. There is a test for each of the three rejected cases and one for the accepted S3-compatible case, and the option row in storage-s3.md says where it is rejected.

@github-actions

Copy link
Copy Markdown
Contributor

✅ PR Title Formatted Correctly

The title of this PR match the correct format. Thank you!

@brgr-s
brgr-s merged commit 3ffdfd3 into lakekeeper:main Oct 22, 2026
73 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

STS AssumeRole session policy lacks Principal, breaks vended-credentials on Yandex Object Storage (S3-compatible)

2 participants