* S3: Implement IAM defaults and STS signing key fallback logic * S3: Refactor startup order to init SSE-S3 key manager before IAM * S3: Derive STS signing key from KEK using HKDF for security isolation * S3: Document STS signing key fallback in security.toml * fix(s3api): refine anonymous access logic and secure-by-default behavior - Initialize anonymous identity by default in `NewIdentityAccessManagement` to prevent nil pointer exceptions. - Ensure `ReplaceS3ApiConfiguration` preserves the anonymous identity if not present in the new configuration. - Update `NewIdentityAccessManagement` signature to accept `filerClient`. - In legacy mode (no policy engine), anonymous defaults to Deny (no actions), preserving secure-by-default behavior. - Use specific `LookupAnonymous` method instead of generic map lookup. - Update tests to accommodate signature changes and verify improved anonymous handling. * feat(s3api): make IAM configuration optional - Start S3 API server without a configuration file if `EnableIam` option is set. - Default to `Allow` effect for policy engine when no configuration is provided (Zero-Config mode). - Handle empty configuration path gracefully in `loadIAMManagerFromConfig`. - Add integration test `iam_optional_test.go` to verify empty config behavior. * fix(iamapi): fix signature mismatch in NewIdentityAccessManagementWithStore * fix(iamapi): properly initialize FilerClient instead of passing nil * fix(iamapi): properly initialize filer client for IAM management - Instead of passing `nil`, construct a `wdclient.FilerClient` using the provided `Filers` addresses. - Ensure `NewIdentityAccessManagementWithStore` receives a valid `filerClient` to avoid potential nil pointer dereferences or limited functionality. * clean: remove dead code in s3api_server.go * refactor(s3api): improve IAM initialization, safety and anonymous access security * fix(s3api): ensure IAM config loads from filer after client init * fix(s3): resolve test failures in integration, CORS, and tagging tests - Fix CORS tests by providing explicit anonymous permissions config - Fix S3 integration tests by setting admin credentials in init - Align tagging test credentials in CI with IAM defaults - Added goroutine to retry IAM config load in iamapi server * fix(s3): allow anonymous access to health targets and S3 Tables when identities are present * fix(ci): use /healthz for Caddy health check in awscli tests * iam, s3api: expose DefaultAllow from IAM and Policy Engine This allows checking the global "Open by Default" configuration from other components like S3 Tables. * s3api/s3tables: support DefaultAllow in permission logic and handler Updated CheckPermissionWithContext to respect the DefaultAllow flag in PolicyContext. This enables "Open by Default" behavior for unauthenticated access in zero-config environments. Added a targeted unit test to verify the logic. * s3api/s3tables: propagate DefaultAllow through handlers Propagated the DefaultAllow flag to individual handlers for namespaces, buckets, tables, policies, and tagging. This ensures consistent "Open by Default" behavior across all S3 Tables API endpoints. * s3api: wire up DefaultAllow for S3 Tables API initialization Updated registerS3TablesRoutes to query the global IAM configuration and set the DefaultAllow flag on the S3 Tables API server. This completes the end-to-end propagation required for anonymous access in zero-config environments. Added a SetDefaultAllow method to S3TablesApiServer to facilitate this. * s3api: fix tests by adding DefaultAllow to mock IAM integrations The IAMIntegration interface was updated to include DefaultAllow(), breaking several mock implementations in tests. This commit fixes the build errors by adding the missing method to the mocks. * env * ensure ports * env * env * fix default allow * add one more test using non-anonymous user * debug * add more debug * less logs
162 lines
4.8 KiB
YAML
162 lines
4.8 KiB
YAML
name: "S3 Keycloak Integration Tests"
|
|
|
|
on:
|
|
pull_request:
|
|
paths:
|
|
- 'weed/iam/**'
|
|
- 'weed/s3api/**'
|
|
- 'test/s3/iam/**'
|
|
- '.github/workflows/s3-keycloak-tests.yml'
|
|
push:
|
|
branches: [ master ]
|
|
paths:
|
|
- 'weed/iam/**'
|
|
- 'weed/s3api/**'
|
|
- 'test/s3/iam/**'
|
|
- '.github/workflows/s3-keycloak-tests.yml'
|
|
|
|
concurrency:
|
|
group: ${{ github.head_ref }}/s3-keycloak-tests
|
|
cancel-in-progress: true
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
defaults:
|
|
run:
|
|
working-directory: weed
|
|
|
|
jobs:
|
|
# Dedicated job for Keycloak integration tests
|
|
s3-keycloak-integration-tests:
|
|
name: S3 Keycloak Integration Tests
|
|
runs-on: ubuntu-22.04
|
|
timeout-minutes: 30
|
|
|
|
steps:
|
|
- name: Check out code
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v6
|
|
with:
|
|
go-version-file: 'go.mod'
|
|
id: go
|
|
|
|
- name: Install SeaweedFS
|
|
working-directory: weed
|
|
run: |
|
|
go install -buildvcs=false
|
|
|
|
- name: Run Keycloak Integration Tests
|
|
timeout-minutes: 25
|
|
working-directory: test/s3/iam
|
|
run: |
|
|
set -x
|
|
echo "=== System Information ==="
|
|
uname -a
|
|
free -h
|
|
df -h
|
|
echo "=== Starting S3 Keycloak Integration Tests ==="
|
|
|
|
# Set WEED_BINARY to use the installed version
|
|
export WEED_BINARY=$(which weed)
|
|
export TEST_TIMEOUT=20m
|
|
|
|
echo "Running Keycloak integration tests..."
|
|
# Start Keycloak container first
|
|
docker run -d \
|
|
--name keycloak \
|
|
-p 8080:8080 \
|
|
-e KC_BOOTSTRAP_ADMIN_USERNAME=admin \
|
|
-e KC_BOOTSTRAP_ADMIN_PASSWORD=admin \
|
|
-e KC_HTTP_ENABLED=true \
|
|
-e KC_HOSTNAME_STRICT=false \
|
|
-e KC_HOSTNAME_STRICT_HTTPS=false \
|
|
quay.io/keycloak/keycloak:26.0 \
|
|
start-dev
|
|
|
|
# Wait for Keycloak with better health checking
|
|
timeout 300 bash -c '
|
|
while true; do
|
|
if curl -s http://localhost:8080/health/ready > /dev/null 2>&1; then
|
|
echo "✅ Keycloak health check passed"
|
|
break
|
|
fi
|
|
echo "... waiting for Keycloak to be ready"
|
|
sleep 5
|
|
done
|
|
'
|
|
|
|
# Setup Keycloak configuration
|
|
./setup_keycloak.sh
|
|
|
|
# Start SeaweedFS services
|
|
make clean setup start-services wait-for-services
|
|
|
|
# Verify service accessibility
|
|
echo "=== Verifying Service Accessibility ==="
|
|
curl -f http://localhost:8080/realms/master
|
|
curl -s http://localhost:8333/healthz
|
|
echo "✅ SeaweedFS S3 API is responding (IAM-protected endpoint)"
|
|
|
|
# Run Keycloak-specific tests
|
|
echo "=== Running Keycloak Tests ==="
|
|
export KEYCLOAK_URL=http://localhost:8080
|
|
export S3_ENDPOINT=http://localhost:8333
|
|
|
|
# Wait for realm to be properly configured
|
|
timeout 120 bash -c 'until curl -fs http://localhost:8080/realms/seaweedfs-test/.well-known/openid-configuration > /dev/null; do echo "... waiting for realm"; sleep 3; done'
|
|
|
|
# Run the Keycloak integration tests
|
|
go test -v -timeout 20m -run "TestKeycloak" ./...
|
|
|
|
- name: Show server logs on failure
|
|
if: failure()
|
|
working-directory: test/s3/iam
|
|
run: |
|
|
echo "=== Service Logs ==="
|
|
echo "--- Keycloak logs ---"
|
|
docker logs keycloak --tail=100 || echo "No Keycloak container logs"
|
|
|
|
echo "--- SeaweedFS Master logs ---"
|
|
if [ -f weed-master.log ]; then
|
|
tail -100 weed-master.log
|
|
fi
|
|
|
|
echo "--- SeaweedFS S3 logs ---"
|
|
if [ -f weed-s3.log ]; then
|
|
tail -100 weed-s3.log
|
|
fi
|
|
|
|
echo "--- SeaweedFS Filer logs ---"
|
|
if [ -f weed-filer.log ]; then
|
|
tail -100 weed-filer.log
|
|
fi
|
|
|
|
echo "=== System Status ==="
|
|
ps aux | grep -E "(weed|keycloak)" || true
|
|
netstat -tlnp | grep -E "(8333|9333|8080|8888)" || true
|
|
docker ps -a || true
|
|
|
|
- name: Cleanup
|
|
if: always()
|
|
working-directory: test/s3/iam
|
|
run: |
|
|
# Stop Keycloak container
|
|
docker stop keycloak || true
|
|
docker rm keycloak || true
|
|
|
|
# Stop SeaweedFS services
|
|
make clean || true
|
|
|
|
- name: Upload test logs on failure
|
|
if: failure()
|
|
uses: actions/upload-artifact@v6
|
|
with:
|
|
name: s3-keycloak-test-logs
|
|
path: |
|
|
test/s3/iam/*.log
|
|
test/s3/iam/test-volume-data/
|
|
retention-days: 3
|