Skip to content

feat(services/swift): add Keystone v3 authentication - #7216

Open
benroeder wants to merge 1 commit into
apache:mainfrom
benroeder:swift/keystone-auth
Open

benroeder wants to merge 1 commit into
apache:mainfrom
benroeder:swift/keystone-auth

Conversation

@benroeder

Copy link
Copy Markdown
Contributor

Summary

  • Fixes feat: Swift service should support Keystone v3 authentication #7215
  • Add native Keystone v3 password authentication with automatic token acquisition and refresh
  • Tokens are refreshed with a 2-minute grace period before expiry
  • Swift storage URL can be discovered from the Keystone service catalog or provided explicitly
  • Two auth modes: static token (existing, backward compatible) or Keystone v3 (new)
  • New config fields: auth_url, username, password, project_name, user_domain_name, project_domain_name
  • Adds mea dependency for async mutex (same as other OpenDAL services)
  • Includes 9 unit tests for catalog extraction, response parsing, and signer lifecycle

Reference: https://docs.openstack.org/keystone/latest/api_curl_examples.html

Test plan

  • All 93 behavior tests pass with Keystone v3 auth against a real OpenStack Swift cluster
  • All 93 behavior tests pass with static token against local SAIO (backward compatibility)
  • Unit tests cover: catalog extraction (normal, missing, trailing slash, prefers public), Keystone response parsing (full and minimal), timestamp parsing, static signer never-expire, Keystone signer starts-expired

Add native Keystone v3 password authentication with automatic token
acquisition and refresh. Tokens are refreshed with a 2-minute grace
period before expiry. The Swift storage URL can be discovered from
the Keystone service catalog or provided explicitly.

Two authentication modes:
- Static token (existing behavior): provide token and endpoint directly
- Keystone v3 (new): provide auth_url, username, password, project_name

Backward compatible — existing token-based configs continue to work.

Reference: https://docs.openstack.org/keystone/latest/api_curl_examples.html
@benroeder
benroeder requested a review from Xuanwo as a code owner February 23, 2026 00:59
@dosubot dosubot Bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Feb 23, 2026
@dosubot

dosubot Bot commented Feb 23, 2026

Copy link
Copy Markdown

Related Documentation

Checked 0 published document(s) in 1 knowledge base(s). No updates required.

How did I do? Any feedback?  Join Discord

@dosubot dosubot Bot added the releases-note/feat The PR implements a new feature or has a title that begins with "feat" label Feb 23, 2026
use std::sync::OnceLock;

/// Authentication mode for Swift.
pub enum SwiftAuth {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest we implement that logic within reqsign: https://github.com/apache/opendal-reqsign. This way, OpenDAL can focus more on storage-side logic.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok will look into it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that opendal uses v0.16.x branch and main is v0.19.0 should I add it to both ? @Xuanwo

@benroeder

Copy link
Copy Markdown
Contributor Author

Update: I've submitted both PRs to opendal-reqsign:

Both add services-openstack with Keystone v3 password auth, token
caching, service catalog parsing, and request signing. Tested against
a real Keystone cluster.

Once the v0.16.x PR is merged and released, I'll update this PR to
use reqsign for the auth instead of the inline implementation.

Xuanwo added a commit to apache/reqsign that referenced this pull request Oct 22, 2026
## Summary

- Add `reqsign-openstack-keystone` crate implementing Keystone v3
password authentication
- Wire into the `reqsign` umbrella crate behind the `openstack` feature
flag
- Add CI workflow with mock server integration tests

This enables OpenDAL's Swift backend to use reqsign for credential
management instead of inline Keystone auth code. Contributes to #685
(`reqsign-swift` checklist item).

Context: Xuanwo requested this move during review of
[apache/opendal#7216](apache/opendal#7216).

## What's included

**Credential types** (`credential.rs`):
- `Credential` with token, expiry, and service catalog
- `CatalogEntry` / `Endpoint` types with serde deserialization
- `endpoint()` and `endpoint_in_region()` for catalog lookup
- `SigningCredential` impl with 2-minute expiry grace period

**Request signing** (`sign_request.rs`):
- `RequestSigner` inserts `X-Auth-Token` header (marked sensitive)

**Credential providers** (`provide_credential/`):
- `KeystoneCredentialProvider` — POST to `{auth_url}/auth/tokens`,
extracts token from `X-Subject-Token` header, parses expiry + service
catalog
- `EnvCredentialProvider` — reads `OPENSTACK_AUTH_URL`,
`OPENSTACK_USERNAME`, `OPENSTACK_PASSWORD`, etc.
- `DefaultCredentialProvider` — credential chain (env vars for now)

**Testing** (27 tests total):
- 16 unit tests covering credential validity, catalog lookup, region
filtering, edge cases, serde, auth request building
- 11 integration tests with Python mock Keystone server: scoped/unscoped
tokens, bad credentials, connection refused, full `Signer` round-trip
with token caching, region filtering
- Also tested against a production OpenStack Keystone v3 deployment —
confirmed token acquisition, timestamp parsing, and service catalog
parsing with multiple services and regions

## Test plan

- [x] `cargo fmt --all -- --check`
- [x] `cargo clippy --workspace --all-targets --all-features -- -D
warnings`
- [x] `cargo test --workspace --no-fail-fast` (all 27 openstack-keystone
tests + full workspace green)
- [x] Mock server integration tests via CI workflow
- [x] Verified against production Keystone v3 cluster

---------

Co-authored-by: Xuanwo <github@xuanwo.io>
@Xuanwo

Xuanwo commented Nov 20, 2026

Copy link
Copy Markdown
Member

The upstream dependency is ready. reqsign-openstack-keystone 3.0.0 is published after apache/reqsign#690 merged. OpenDAL main already uses reqsign-core 3.3.3, and S3 uses reqsign-aws-v4 3.4.0 and reqsign-file-read-tokio 3.0.8. Crate release · S3 dependencies

Could you rebase onto main and replace the inline Keystone v3 authentication in services/swift with reqsign-openstack-keystone, following the earlier review? S3 shows how to pass the operation HTTP transport to reqsign. Could you also share updated Swift behavior-test results for the rebased PR against a real Keystone v3 and Swift deployment or a fixture that runs both services? S3 transport integration

(This comment was generated by AI.)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

releases-note/feat The PR implements a new feature or has a title that begins with "feat" size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Swift service should support Keystone v3 authentication

2 participants