This resolves GitHub issue #7747 by extracting duplicated IAM code into a shared package that both the embedded S3 IAM and standalone IAM use. New shared package (weed/iam/): - constants.go: Common constants (charsets, action strings, error messages) - helpers.go: Shared helper functions (Hash, GenerateRandomString, GenerateAccessKeyId, GenerateSecretAccessKey, StringSlicesEqual, MapToStatementAction, MapToIdentitiesAction, MaskAccessKey) - responses.go: Common IAM response structs (CommonResponse, ListUsersResponse, CreateUserResponse, etc.) - helpers_test.go: Unit tests for shared helpers Updated files: - weed/s3api/s3api_embedded_iam.go: Use type aliases and function wrappers to the shared package, removing ~200 lines of duplicated code - weed/iamapi/iamapi_management_handlers.go: Use shared package for constants and helper functions, removing ~100 lines of duplicated code - weed/iamapi/iamapi_response.go: Re-export types from shared package for backwards compatibility Benefits: - Single source of truth for IAM constants and helpers - Easier maintenance - changes only need to be made in one place - Reduced risk of inconsistencies between embedded and standalone IAM - Better test coverage through shared test suite
27 lines
1.0 KiB
Go
27 lines
1.0 KiB
Go
package iamapi
|
|
|
|
// This file re-exports IAM response types from the shared weed/iam package
|
|
// for backwards compatibility with existing code.
|
|
|
|
import (
|
|
iamlib "github.com/seaweedfs/seaweedfs/weed/iam"
|
|
)
|
|
|
|
// Type aliases for IAM response types from shared package
|
|
type (
|
|
CommonResponse = iamlib.CommonResponse
|
|
ListUsersResponse = iamlib.ListUsersResponse
|
|
ListAccessKeysResponse = iamlib.ListAccessKeysResponse
|
|
DeleteAccessKeyResponse = iamlib.DeleteAccessKeyResponse
|
|
CreatePolicyResponse = iamlib.CreatePolicyResponse
|
|
CreateUserResponse = iamlib.CreateUserResponse
|
|
DeleteUserResponse = iamlib.DeleteUserResponse
|
|
GetUserResponse = iamlib.GetUserResponse
|
|
UpdateUserResponse = iamlib.UpdateUserResponse
|
|
CreateAccessKeyResponse = iamlib.CreateAccessKeyResponse
|
|
PutUserPolicyResponse = iamlib.PutUserPolicyResponse
|
|
DeleteUserPolicyResponse = iamlib.DeleteUserPolicyResponse
|
|
GetUserPolicyResponse = iamlib.GetUserPolicyResponse
|
|
ErrorResponse = iamlib.ErrorResponse
|
|
)
|