This document explains how to configure and deploy the STS (Security Token Service) for distributed SeaweedFS S3 Gateway deployments with consistent identity provider configurations.
Previously, identity providers had to be manually registered on each S3 gateway instance, leading to:
The STS service now supports automatic provider loading from configuration files, ensuring:
{
"sts": {
"tokenDuration": "1h",
"maxSessionLength": "12h",
"issuer": "seaweedfs-sts",
"signingKey": "base64-encoded-signing-key-32-chars-min"
}
}
Note: The STS service uses a stateless JWT design where all session information is embedded directly in the JWT token. No external session storage is required.
{
"sts": {
"tokenDuration": "1h",
"maxSessionLength": "12h",
"issuer": "seaweedfs-sts",
"signingKey": "base64-encoded-signing-key",
"providers": [
{
"name": "keycloak-oidc",
"type": "oidc",
"enabled": true,
"config": {
"issuer": "https://keycloak.company.com/realms/seaweedfs",
"clientId": "seaweedfs-s3",
"clientSecret": "super-secret-key",
"jwksUri": "https://keycloak.company.com/realms/seaweedfs/protocol/openid-connect/certs",
"scopes": ["openid", "profile", "email", "roles"],
"claimsMapping": {
"usernameClaim": "preferred_username",
"groupsClaim": "roles"
}
}
},
{
"name": "backup-oidc",
"type": "oidc",
"enabled": false,
"config": {
"issuer": "https://backup-oidc.company.com",
"clientId": "seaweedfs-backup"
}
},
{
"name": "dev-mock-provider",
"type": "mock",
"enabled": true,
"config": {
"issuer": "http://localhost:9999",
"clientId": "mock-client"
}
}
]
}
}
"type": "oidc")For production authentication with OpenID Connect providers like Keycloak, Auth0, Google, etc.
Required Configuration:
issuer: OIDC issuer URLclientId: OAuth2 client IDOptional Configuration:
clientSecret: OAuth2 client secret (for confidential clients)jwksUri: JSON Web Key Set URI (auto-discovered if not provided)userInfoUri: UserInfo endpoint URI (auto-discovered if not provided)scopes: OAuth2 scopes to request (default: ["openid"])claimsMapping: Map OIDC claims to identity attributesExample:
{
"name": "corporate-keycloak",
"type": "oidc",
"enabled": true,
"config": {
"issuer": "https://sso.company.com/realms/production",
"clientId": "seaweedfs-prod",
"clientSecret": "confidential-secret",
"scopes": ["openid", "profile", "email", "groups"],
"claimsMapping": {
"usernameClaim": "preferred_username",
"groupsClaim": "groups",
"emailClaim": "email"
}
}
}
"type": "mock")For development, testing, and staging environments.
Configuration:
issuer: Mock issuer URL (default: http://localhost:9999)clientId: Mock client IDExample:
{
"name": "dev-mock",
"type": "mock",
"enabled": true,
"config": {
"issuer": "http://dev-mock:9999",
"clientId": "dev-client"
}
}
Built-in Test Tokens:
valid_test_token: Returns test user with developer groupsvalid-oidc-token: Compatible with integration testsexpired_token: Returns token expired errorinvalid_token: Returns invalid token errorThe factory pattern supports easy addition of new provider types:
"type": "ldap": LDAP/Active Directory authentication"type": "saml": SAML 2.0 authentication"type": "oauth2": Generic OAuth2 providers"type": "custom": Custom authentication backends# Standard deployment with config-driven providers
weed s3 -filer=localhost:8888 -port=8333 -iam.config=/path/to/sts_config.json
# Instance 1
weed s3 -filer=prod-filer:8888 -port=8333 -iam.config=/shared/sts_distributed.json
# Instance 2
weed s3 -filer=prod-filer:8888 -port=8334 -iam.config=/shared/sts_distributed.json
# Instance N
weed s3 -filer=prod-filer:8888 -port=833N -iam.config=/shared/sts_distributed.json
Critical Requirements for Distributed Deployment:
signingKey valuesissuer valueNote: STS now uses stateless JWT tokens, eliminating the need for shared session storage.
# docker-compose.yml for production deployment
services:
filer:
image: seaweedfs/seaweedfs:latest
command: "filer -master=master:9333"
volumes:
- filer-data:/data
s3-gateway-1:
image: seaweedfs/seaweedfs:latest
command: "s3 -filer=filer:8888 -port=8333 -iam.config=/config/sts_distributed.json"
ports:
- "8333:8333"
volumes:
- ./sts_distributed.json:/config/sts_distributed.json:ro
depends_on: [filer]
s3-gateway-2:
image: seaweedfs/seaweedfs:latest
command: "s3 -filer=filer:8888 -port=8333 -iam.config=/config/sts_distributed.json"
ports:
- "8334:8333"
volumes:
- ./sts_distributed.json:/config/sts_distributed.json:ro
depends_on: [filer]
s3-gateway-3:
image: seaweedfs/seaweedfs:latest
command: "s3 -filer=filer:8888 -port=8333 -iam.config=/config/sts_distributed.json"
ports:
- "8335:8333"
volumes:
- ./sts_distributed.json:/config/sts_distributed.json:ro
depends_on: [filer]
load-balancer:
image: nginx:alpine
ports:
- "80:80"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
depends_on: [s3-gateway-1, s3-gateway-2, s3-gateway-3]
1. User authenticates with OIDC provider (Keycloak, Auth0, etc.)
↓
2. User receives OIDC JWT token from provider
↓
3. User calls SeaweedFS STS AssumeRoleWithWebIdentity
POST /sts/assume-role-with-web-identity
{
"RoleArn": "arn:seaweed:iam::role/S3AdminRole",
"WebIdentityToken": "eyJ0eXAiOiJKV1QiLCJhbGc...",
"RoleSessionName": "user-session"
}
↓
4. STS validates OIDC token with configured provider
- Verifies JWT signature using provider's JWKS
- Validates issuer, audience, expiration
- Extracts user identity and groups
↓
5. STS checks role trust policy
- Verifies user/groups can assume the requested role
- Validates conditions in trust policy
↓
6. STS generates temporary credentials
- Creates temporary access key, secret key, session token
- Session token is signed JWT with all session information embedded (stateless)
↓
7. User receives temporary credentials
{
"Credentials": {
"AccessKeyId": "AKIA...",
"SecretAccessKey": "base64-secret",
"SessionToken": "eyJ0eXAiOiJKV1QiLCJhbGc...",
"Expiration": "2024-01-01T12:00:00Z"
}
}
↓
8. User makes S3 requests with temporary credentials
- AWS SDK signs requests with temporary credentials
- SeaweedFS S3 gateway validates session token
- Gateway checks permissions via policy engine
User Request → Load Balancer → Any S3 Gateway Instance
↓
Extract JWT Session Token
↓
Validate JWT Token
(Self-contained - no external storage needed)
↓
Check Permissions
(Shared policy engine)
↓
Allow/Deny Request
{
"sts": {
"tokenDuration": "1h",
"maxSessionLength": "12h",
"issuer": "seaweedfs-dev-sts",
"signingKey": "ZGV2LXNpZ25pbmcta2V5LTMyLWNoYXJhY3RlcnMtbG9uZw==",
"providers": [
{
"name": "dev-mock",
"type": "mock",
"enabled": true,
"config": {
"issuer": "http://localhost:9999",
"clientId": "dev-mock-client"
}
}
]
}
}
{
"sts": {
"tokenDuration": "1h",
"maxSessionLength": "12h",
"issuer": "seaweedfs-prod-sts",
"signingKey": "cHJvZC1zaWduaW5nLWtleS0zMi1jaGFyYWN0ZXJzLWxvbmctcmFuZG9t",
"providers": [
{
"name": "corporate-sso",
"type": "oidc",
"enabled": true,
"config": {
"issuer": "https://sso.company.com/realms/production",
"clientId": "seaweedfs-prod",
"clientSecret": "${SSO_CLIENT_SECRET}",
"scopes": ["openid", "profile", "email", "groups"],
"claimsMapping": {
"usernameClaim": "preferred_username",
"groupsClaim": "groups"
}
}
},
{
"name": "backup-auth",
"type": "oidc",
"enabled": false,
"config": {
"issuer": "https://backup-sso.company.com",
"clientId": "seaweedfs-backup"
}
}
]
}
}
Before (Manual Registration):
// Each instance needs this code
keycloakProvider := oidc.NewOIDCProvider("keycloak-oidc")
keycloakProvider.Initialize(keycloakConfig)
stsService.RegisterProvider(keycloakProvider)
After (Configuration-Driven):
{
"sts": {
"providers": [
{
"name": "keycloak-oidc",
"type": "oidc",
"enabled": true,
"config": {
"issuer": "https://keycloak.company.com/realms/seaweedfs",
"clientId": "seaweedfs-s3"
}
}
]
}
}
Symptoms: Authentication works on some instances but not others Diagnosis:
# Check provider counts on each instance
curl http://instance1:8333/sts/providers | jq '.providers | length'
curl http://instance2:8334/sts/providers | jq '.providers | length'
Solution: Ensure all instances use identical configuration files
Symptoms: "Invalid signature" or "Invalid issuer" errors
Diagnosis: Check signing key and issuer consistency
Solution: Verify signingKey and issuer are identical across all instances
Symptoms: Providers not loaded at startup Diagnosis: Check logs for provider initialization errors Solution: Validate provider configuration against schema
Symptoms: "Failed to fetch JWKS" errors Diagnosis: Test OIDC provider connectivity from all instances Solution: Check network connectivity, DNS resolution, certificates
# Test configuration loading
weed s3 -iam.config=/path/to/config.json -test.config
# Validate JWT tokens
curl -X POST http://localhost:8333/sts/validate-token \
-H "Content-Type: application/json" \
-d '{"sessionToken": "eyJ0eXAiOiJKV1QiLCJhbGc..."}'
# List loaded providers
curl http://localhost:8333/sts/providers
# Check session store
curl http://localhost:8333/sts/sessions/count
The configuration-driven provider system solves critical distributed deployment issues:
This enables SeaweedFS S3 Gateway to scale horizontally with consistent authentication across all instances, making it truly production-ready for enterprise deployments.