mirror of
https://github.com/pocket-id/pocket-id.git
synced 2025-12-06 05:12:57 +03:00
feat: add option to disable S3 integrity check
This commit is contained in:
@@ -38,13 +38,14 @@ func Bootstrap(ctx context.Context) error {
|
|||||||
fileStorage, err = storage.NewDatabaseStorage(db)
|
fileStorage, err = storage.NewDatabaseStorage(db)
|
||||||
case storage.TypeS3:
|
case storage.TypeS3:
|
||||||
s3Cfg := storage.S3Config{
|
s3Cfg := storage.S3Config{
|
||||||
Bucket: common.EnvConfig.S3Bucket,
|
Bucket: common.EnvConfig.S3Bucket,
|
||||||
Region: common.EnvConfig.S3Region,
|
Region: common.EnvConfig.S3Region,
|
||||||
Endpoint: common.EnvConfig.S3Endpoint,
|
Endpoint: common.EnvConfig.S3Endpoint,
|
||||||
AccessKeyID: common.EnvConfig.S3AccessKeyID,
|
AccessKeyID: common.EnvConfig.S3AccessKeyID,
|
||||||
SecretAccessKey: common.EnvConfig.S3SecretAccessKey,
|
SecretAccessKey: common.EnvConfig.S3SecretAccessKey,
|
||||||
ForcePathStyle: common.EnvConfig.S3ForcePathStyle,
|
ForcePathStyle: common.EnvConfig.S3ForcePathStyle,
|
||||||
Root: common.EnvConfig.UploadPath,
|
DisableDefaultIntegrityChecks: common.EnvConfig.S3DisableDefaultIntegrityChecks,
|
||||||
|
Root: common.EnvConfig.UploadPath,
|
||||||
}
|
}
|
||||||
fileStorage, err = storage.NewS3Storage(ctx, s3Cfg)
|
fileStorage, err = storage.NewS3Storage(ctx, s3Cfg)
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -38,38 +38,39 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type EnvConfigSchema struct {
|
type EnvConfigSchema struct {
|
||||||
AppEnv AppEnv `env:"APP_ENV" options:"toLower"`
|
AppEnv AppEnv `env:"APP_ENV" options:"toLower"`
|
||||||
LogLevel string `env:"LOG_LEVEL" options:"toLower"`
|
LogLevel string `env:"LOG_LEVEL" options:"toLower"`
|
||||||
AppURL string `env:"APP_URL" options:"toLower,trimTrailingSlash"`
|
AppURL string `env:"APP_URL" options:"toLower,trimTrailingSlash"`
|
||||||
DbProvider DbProvider `env:"DB_PROVIDER" options:"toLower"`
|
DbProvider DbProvider `env:"DB_PROVIDER" options:"toLower"`
|
||||||
DbConnectionString string `env:"DB_CONNECTION_STRING" options:"file"`
|
DbConnectionString string `env:"DB_CONNECTION_STRING" options:"file"`
|
||||||
FileBackend string `env:"FILE_BACKEND" options:"toLower"`
|
FileBackend string `env:"FILE_BACKEND" options:"toLower"`
|
||||||
UploadPath string `env:"UPLOAD_PATH"`
|
UploadPath string `env:"UPLOAD_PATH"`
|
||||||
S3Bucket string `env:"S3_BUCKET"`
|
S3Bucket string `env:"S3_BUCKET"`
|
||||||
S3Region string `env:"S3_REGION"`
|
S3Region string `env:"S3_REGION"`
|
||||||
S3Endpoint string `env:"S3_ENDPOINT"`
|
S3Endpoint string `env:"S3_ENDPOINT"`
|
||||||
S3AccessKeyID string `env:"S3_ACCESS_KEY_ID"`
|
S3AccessKeyID string `env:"S3_ACCESS_KEY_ID"`
|
||||||
S3SecretAccessKey string `env:"S3_SECRET_ACCESS_KEY"`
|
S3SecretAccessKey string `env:"S3_SECRET_ACCESS_KEY"`
|
||||||
S3ForcePathStyle bool `env:"S3_FORCE_PATH_STYLE"`
|
S3ForcePathStyle bool `env:"S3_FORCE_PATH_STYLE"`
|
||||||
KeysPath string `env:"KEYS_PATH"`
|
S3DisableDefaultIntegrityChecks bool `env:"S3_DISABLE_DEFAULT_INTEGRITY_CHECKS"`
|
||||||
KeysStorage string `env:"KEYS_STORAGE"`
|
KeysPath string `env:"KEYS_PATH"`
|
||||||
EncryptionKey []byte `env:"ENCRYPTION_KEY" options:"file"`
|
KeysStorage string `env:"KEYS_STORAGE"`
|
||||||
Port string `env:"PORT"`
|
EncryptionKey []byte `env:"ENCRYPTION_KEY" options:"file"`
|
||||||
Host string `env:"HOST" options:"toLower"`
|
Port string `env:"PORT"`
|
||||||
UnixSocket string `env:"UNIX_SOCKET"`
|
Host string `env:"HOST" options:"toLower"`
|
||||||
UnixSocketMode string `env:"UNIX_SOCKET_MODE"`
|
UnixSocket string `env:"UNIX_SOCKET"`
|
||||||
MaxMindLicenseKey string `env:"MAXMIND_LICENSE_KEY" options:"file"`
|
UnixSocketMode string `env:"UNIX_SOCKET_MODE"`
|
||||||
GeoLiteDBPath string `env:"GEOLITE_DB_PATH"`
|
MaxMindLicenseKey string `env:"MAXMIND_LICENSE_KEY" options:"file"`
|
||||||
GeoLiteDBUrl string `env:"GEOLITE_DB_URL"`
|
GeoLiteDBPath string `env:"GEOLITE_DB_PATH"`
|
||||||
LocalIPv6Ranges string `env:"LOCAL_IPV6_RANGES"`
|
GeoLiteDBUrl string `env:"GEOLITE_DB_URL"`
|
||||||
UiConfigDisabled bool `env:"UI_CONFIG_DISABLED"`
|
LocalIPv6Ranges string `env:"LOCAL_IPV6_RANGES"`
|
||||||
MetricsEnabled bool `env:"METRICS_ENABLED"`
|
UiConfigDisabled bool `env:"UI_CONFIG_DISABLED"`
|
||||||
TracingEnabled bool `env:"TRACING_ENABLED"`
|
MetricsEnabled bool `env:"METRICS_ENABLED"`
|
||||||
LogJSON bool `env:"LOG_JSON"`
|
TracingEnabled bool `env:"TRACING_ENABLED"`
|
||||||
TrustProxy bool `env:"TRUST_PROXY"`
|
LogJSON bool `env:"LOG_JSON"`
|
||||||
AnalyticsDisabled bool `env:"ANALYTICS_DISABLED"`
|
TrustProxy bool `env:"TRUST_PROXY"`
|
||||||
AllowDowngrade bool `env:"ALLOW_DOWNGRADE"`
|
AnalyticsDisabled bool `env:"ANALYTICS_DISABLED"`
|
||||||
InternalAppURL string `env:"INTERNAL_APP_URL"`
|
AllowDowngrade bool `env:"ALLOW_DOWNGRADE"`
|
||||||
|
InternalAppURL string `env:"INTERNAL_APP_URL"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var EnvConfig = defaultConfig()
|
var EnvConfig = defaultConfig()
|
||||||
|
|||||||
@@ -18,13 +18,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type S3Config struct {
|
type S3Config struct {
|
||||||
Bucket string
|
Bucket string
|
||||||
Region string
|
Region string
|
||||||
Endpoint string
|
Endpoint string
|
||||||
AccessKeyID string
|
AccessKeyID string
|
||||||
SecretAccessKey string
|
SecretAccessKey string
|
||||||
ForcePathStyle bool
|
ForcePathStyle bool
|
||||||
Root string
|
DisableDefaultIntegrityChecks bool
|
||||||
|
Root string
|
||||||
}
|
}
|
||||||
|
|
||||||
type s3Storage struct {
|
type s3Storage struct {
|
||||||
@@ -44,6 +45,10 @@ func NewS3Storage(ctx context.Context, cfg S3Config) (FileStorage, error) {
|
|||||||
o.BaseEndpoint = aws.String(cfg.Endpoint)
|
o.BaseEndpoint = aws.String(cfg.Endpoint)
|
||||||
}
|
}
|
||||||
o.UsePathStyle = cfg.ForcePathStyle
|
o.UsePathStyle = cfg.ForcePathStyle
|
||||||
|
if cfg.DisableDefaultIntegrityChecks {
|
||||||
|
o.RequestChecksumCalculation = aws.RequestChecksumCalculationWhenRequired
|
||||||
|
o.ResponseChecksumValidation = aws.ResponseChecksumValidationWhenRequired
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
return &s3Storage{
|
return &s3Storage{
|
||||||
|
|||||||
Reference in New Issue
Block a user