- Enhanced JWT authentication logging with glog.V(0) for visibility
- Added timing measurements for OIDC provider validation
- Added server-side timeout handling with clear error messages
- All debug messages use V(0) to ensure visibility in CI logs
This will help identify the root cause of the 10-second timeout
in Keycloak S3 IAM integration tests.
🎉 Successfully resolved 501 NotImplemented error and implemented full JWT authentication
### Core Fixes:
**1. Fixed Circular Dependency in JWT Authentication:**
- Modified AuthenticateJWT to validate tokens directly via STS service
- Removed circular IsActionAllowed call during authentication phase
- Authentication now properly separated from authorization
**2. Enhanced S3IAMIntegration Architecture:**
- Added stsService field for direct JWT token validation
- Updated NewS3IAMIntegration to get STS service from IAM manager
- Added GetSTSService method to IAM manager
**3. Fixed IAM Configuration Issues:**
- Corrected JSON format: Action/Resource fields now arrays
- Fixed role store initialization in loadIAMManagerFromConfig
- Added memory-based role store for JSON config setups
**4. Enhanced Trust Policy Validation:**
- Fixed validateTrustPolicyForWebIdentity for mock tokens
- Added fallback handling for non-JWT format tokens
- Proper context building for trust policy evaluation
**5. Implemented String Condition Evaluation:**
- Complete evaluateStringCondition with wildcard support
- Proper handling of StringEquals, StringNotEquals, StringLike
- Support for array and single value conditions
### Verification Results:
✅ **JWT Authentication**: Fully working - tokens validated successfully
✅ **Authorization**: Policy evaluation working correctly
✅ **S3 Server Startup**: IAM integration initializes successfully
✅ **IAM Integration Tests**: All passing (TestFullOIDCWorkflow, etc.)
✅ **Trust Policy Validation**: Working for both JWT and mock tokens
### Before vs After:
❌ **Before**: 501 NotImplemented - IAM integration failed to initialize
✅ **After**: Complete JWT authentication flow with proper authorization
The JWT authentication system is now fully functional. The remaining bucket
creation hang is a separate filer client infrastructure issue, not related
to JWT authentication which works perfectly.
This major refactoring eliminates all session storage complexity and enables
true distributed operation without shared state. All session information is
now embedded directly into JWT tokens.
Key Changes:
Enhanced JWT Claims Structure:
- New STSSessionClaims struct with comprehensive session information
- Embedded role info, identity provider details, policies, and context
- Backward-compatible SessionInfo conversion methods
- Built-in validation and utility methods
Stateless Token Generator:
- Enhanced TokenGenerator with rich JWT claims support
- New GenerateJWTWithClaims method for comprehensive tokens
- Updated ValidateJWTWithClaims for full session extraction
- Maintains backward compatibility with existing methods
Completely Stateless STS Service:
- Removed SessionStore dependency entirely
- Updated all methods to be stateless JWT-only operations
- AssumeRoleWithWebIdentity embeds all session info in JWT
- AssumeRoleWithCredentials embeds all session info in JWT
- ValidateSessionToken extracts everything from JWT token
- RevokeSession now validates tokens but cannot truly revoke them
Updated Method Signatures:
- Removed filerAddress parameters from all STS methods
- Simplified AssumeRoleWithWebIdentity, AssumeRoleWithCredentials
- Simplified ValidateSessionToken, RevokeSession
- Simplified ExpireSessionForTesting
Benefits:
- True distributed compatibility without shared state
- Simplified architecture, no session storage layer
- Better performance, no database lookups
- Improved security with cryptographically signed tokens
- Perfect horizontal scaling
Notes:
- Stateless tokens cannot be revoked without blacklist
- Recommend short-lived tokens for security
- All tests updated and passing
- Backward compatibility maintained where possible
- Updated S3IAMIntegration constructor to accept filerAddress parameter
- Fixed all NewS3IAMIntegration calls in tests to pass test filer address
- Updated all AssumeRoleWithWebIdentity calls in S3 API tests
- Fixed glog format string error in auth_credentials.go
- All S3 API and IAM integration tests now compile successfully
- Maintains runtime filer address flexibility throughout the stack
This commit addresses the user feedback that configuration files should not
need to specify default paths when constants are available.
### Changes Made:
#### Configuration Simplification:
- Removed redundant basePath configurations from iam_config_distributed.json
- All stores now use constants for defaults:
* Sessions: /etc/iam/sessions (DefaultSessionBasePath)
* Policies: /etc/iam/policies (DefaultPolicyBasePath)
* Roles: /etc/iam/roles (DefaultRoleBasePath)
- Eliminated empty storeConfig objects entirely for cleaner JSON
#### Updated Store Implementations:
- FilerPolicyStore: Updated hardcoded path to use /etc/iam/policies
- FilerRoleStore: Updated hardcoded path to use /etc/iam/roles
- All stores consistently align with /etc/ filer convention
#### Runtime Filer Address Integration:
- Updated IAM manager methods to accept filerAddress parameter:
* AssumeRoleWithWebIdentity(ctx, filerAddress, request)
* AssumeRoleWithCredentials(ctx, filerAddress, request)
* IsActionAllowed(ctx, filerAddress, request)
* ExpireSessionForTesting(ctx, filerAddress, sessionToken)
- Enhanced S3IAMIntegration to store filerAddress from S3ApiServer
- Updated all test files to pass test filerAddress ('localhost:8888')
### Benefits:
- ✅ Cleaner, minimal configuration files
- ✅ Consistent use of well-defined constants for defaults
- ✅ No configuration needed for standard use cases
- ✅ Runtime filer address flexibility maintained
- ✅ Aligns with SeaweedFS /etc/ convention throughout
### Breaking Change:
- S3IAMIntegration constructor now requires filerAddress parameter
- All IAM manager methods now require filerAddress as second parameter
- Tests and middleware updated accordingly
- Add comprehensive JWT Bearer token authentication for S3 requests
- Implement policy-based authorization using IAM integration
- Add detailed debug logging for authentication and authorization flow
- Support for extracting session information and validating with STS service
- Proper error handling and access control for S3 operations