@ -442,11 +442,12 @@ func (iam *IdentityAccessManagement) authRequest(r *http.Request, action Action)
glog . V ( 3 ) . Infof ( "unsigned streaming upload" )
glog . V ( 3 ) . Infof ( "unsigned streaming upload" )
return identity , s3err . ErrNone
return identity , s3err . ErrNone
case authTypeJWT :
case authTypeJWT :
glog . V ( 3 ) . Infof ( "jwt auth type" )
glog . V ( 0 ) . Infof ( "jwt auth type detected, iamIntegration != nil? %t " , iam . iamIntegration != nil )
r . Header . Set ( s3_constants . AmzAuthType , "Jwt" )
r . Header . Set ( s3_constants . AmzAuthType , "Jwt" )
if iam . iamIntegration != nil {
if iam . iamIntegration != nil {
return iam . authenticateJWTWithIAM ( r )
return iam . authenticateJWTWithIAM ( r )
}
}
glog . V ( 0 ) . Infof ( "IAM integration is nil, returning ErrNotImplemented" )
return identity , s3err . ErrNotImplemented
return identity , s3err . ErrNotImplemented
case authTypeAnonymous :
case authTypeAnonymous :
authType = "Anonymous"
authType = "Anonymous"
@ -485,12 +486,16 @@ func (iam *IdentityAccessManagement) authRequest(r *http.Request, action Action)
// ListBuckets operation - authorization handled per-bucket in the handler
// ListBuckets operation - authorization handled per-bucket in the handler
} else {
} else {
// Use enhanced authorization if IAM integration is available
// Use enhanced authorization if IAM integration is available
if iam . iamIntegration != nil && r . Header . Get ( "X-SeaweedFS-Session-Token" ) != "" {
sessionToken := r . Header . Get ( "X-SeaweedFS-Session-Token" )
glog . V ( 0 ) . Infof ( "Authorization check: iamIntegration != nil? %t, sessionToken != \"\"? %t, sessionToken=%s" , iam . iamIntegration != nil , sessionToken != "" , sessionToken )
if iam . iamIntegration != nil && sessionToken != "" {
glog . V ( 0 ) . Infof ( "Using IAM authorization for action=%s, bucket=%s, object=%s" , action , bucket , object )
if errCode := iam . authorizeWithIAM ( r , identity , action , bucket , object ) ; errCode != s3err . ErrNone {
if errCode := iam . authorizeWithIAM ( r , identity , action , bucket , object ) ; errCode != s3err . ErrNone {
return identity , errCode
return identity , errCode
}
}
} else {
} else {
// Fall back to existing authorization
// Fall back to existing authorization
glog . V ( 0 ) . Infof ( "Using fallback authorization for action=%s, bucket=%s, object=%s" , action , bucket , object )
if ! identity . canDo ( action , bucket , object ) {
if ! identity . canDo ( action , bucket , object ) {
return identity , s3err . ErrAccessDenied
return identity , s3err . ErrAccessDenied
}
}
@ -607,8 +612,10 @@ func (iam *IdentityAccessManagement) SetIAMIntegration(integration *S3IAMIntegra
func ( iam * IdentityAccessManagement ) authenticateJWTWithIAM ( r * http . Request ) ( * Identity , s3err . ErrorCode ) {
func ( iam * IdentityAccessManagement ) authenticateJWTWithIAM ( r * http . Request ) ( * Identity , s3err . ErrorCode ) {
ctx := r . Context ( )
ctx := r . Context ( )
glog . V ( 0 ) . Infof ( "authenticateJWTWithIAM: starting JWT authentication" )
// Use IAM integration to authenticate JWT
// Use IAM integration to authenticate JWT
iamIdentity , errCode := iam . iamIntegration . AuthenticateJWT ( ctx , r )
iamIdentity , errCode := iam . iamIntegration . AuthenticateJWT ( ctx , r )
glog . V ( 0 ) . Infof ( "authenticateJWTWithIAM: AuthenticateJWT returned errCode=%s" , errCode )
if errCode != s3err . ErrNone {
if errCode != s3err . ErrNone {
return nil , errCode
return nil , errCode
}
}
@ -624,6 +631,7 @@ func (iam *IdentityAccessManagement) authenticateJWTWithIAM(r *http.Request) (*I
r . Header . Set ( "X-SeaweedFS-Session-Token" , iamIdentity . SessionToken )
r . Header . Set ( "X-SeaweedFS-Session-Token" , iamIdentity . SessionToken )
r . Header . Set ( "X-SeaweedFS-Principal" , iamIdentity . Principal )
r . Header . Set ( "X-SeaweedFS-Principal" , iamIdentity . Principal )
glog . V ( 0 ) . Infof ( "authenticateJWTWithIAM: successfully authenticated, sessionToken=%s, principal=%s" , iamIdentity . SessionToken , iamIdentity . Principal )
return identity , s3err . ErrNone
return identity , s3err . ErrNone
}
}