mirror of
https://github.com/formbricks/formbricks.git
synced 2026-04-25 15:09:03 -05:00
fix: Fix S3 credential checks (#2513)
Co-authored-by: pandeymangg <anshuman.pandey9999@gmail.com>
This commit is contained in:
@@ -147,7 +147,7 @@ These variables can be provided at the runtime i.e. in your docker-compose file.
|
||||
| S3_ACCESS_KEY | Access key for S3. | optional | (resolved by the AWS SDK) |
|
||||
| S3_SECRET_KEY | Secret key for S3. | optional | (resolved by the AWS SDK) |
|
||||
| S3_REGION | Region for S3. | optional | (resolved by the AWS SDK) |
|
||||
| S3_BUCKET_NAME | Bucket name for S3. | optional (required if S3 is enabled) | |
|
||||
| S3_BUCKET_NAME | S3 bucket name for data storage. Formbricks enables S3 storage when this is set. | optional (required if S3 is enabled) | |
|
||||
| S3_ENDPOINT | Endpoint for S3. | optional | (resolved by the AWS SDK) |
|
||||
| PRIVACY_URL | URL for privacy policy. | optional | |
|
||||
| TERMS_URL | URL for terms of service. | optional | |
|
||||
|
||||
@@ -86,9 +86,6 @@ export const DEFAULT_TEAM_ROLE = env.DEFAULT_TEAM_ROLE;
|
||||
export const ONBOARDING_DISABLED = env.ONBOARDING_DISABLED === "1";
|
||||
|
||||
// Storage constants
|
||||
export const AWS_ACCESS_KEY_ID = env.AWS_ACCESS_KEY_ID;
|
||||
export const AWS_SECRET_ACCESS_KEY = env.AWS_SECRET_ACCESS_KEY;
|
||||
export const AWS_REGION = env.AWS_REGION;
|
||||
export const S3_ACCESS_KEY = env.S3_ACCESS_KEY;
|
||||
export const S3_SECRET_KEY = env.S3_SECRET_KEY;
|
||||
export const S3_REGION = env.S3_REGION;
|
||||
@@ -101,17 +98,12 @@ export const MAX_SIZES = {
|
||||
pro: 1024 * 1024 * 1024, // 1GB
|
||||
} as const;
|
||||
|
||||
// Function to check if the necessary S3 configuration is set up
|
||||
export const isS3Configured = () => {
|
||||
// for aws sdk, it can pick up the creds for access key, secret key and the region from the environment variables
|
||||
if (AWS_ACCESS_KEY_ID && AWS_SECRET_ACCESS_KEY && AWS_REGION) {
|
||||
// so we only need to check if the bucket name is set
|
||||
return !!S3_BUCKET_NAME;
|
||||
}
|
||||
|
||||
// for other s3 compatible services, we need to provide the access key and secret key
|
||||
return S3_ACCESS_KEY && S3_SECRET_KEY && (S3_ENDPOINT_URL ? S3_REGION : true) && S3_BUCKET_NAME
|
||||
? true
|
||||
: false;
|
||||
// This function checks if the S3 bucket name environment variable is defined.
|
||||
// The AWS SDK automatically resolves credentials through a chain,
|
||||
// so we do not need to explicitly check for AWS credentials like access key, secret key, or region.
|
||||
return !!S3_BUCKET_NAME;
|
||||
};
|
||||
|
||||
// Pricing
|
||||
|
||||
@@ -8,9 +8,6 @@ export const env = createEnv({
|
||||
*/
|
||||
server: {
|
||||
AIRTABLE_CLIENT_ID: z.string().optional(),
|
||||
AWS_ACCESS_KEY_ID: z.string().optional(),
|
||||
AWS_SECRET_ACCESS_KEY: z.string().optional(),
|
||||
AWS_REGION: z.string().optional(),
|
||||
AZUREAD_CLIENT_ID: z.string().optional(),
|
||||
AZUREAD_CLIENT_SECRET: z.string().optional(),
|
||||
AZUREAD_TENANT_ID: z.string().optional(),
|
||||
@@ -114,9 +111,6 @@ export const env = createEnv({
|
||||
*/
|
||||
runtimeEnv: {
|
||||
AIRTABLE_CLIENT_ID: process.env.AIRTABLE_CLIENT_ID,
|
||||
AWS_ACCESS_KEY_ID: process.env.AWS_ACCESS_KEY_ID,
|
||||
AWS_SECRET_ACCESS_KEY: process.env.AWS_SECRET_ACCESS_KEY,
|
||||
AWS_REGION: process.env.AWS_REGION,
|
||||
AZUREAD_CLIENT_ID: process.env.AZUREAD_CLIENT_ID,
|
||||
AZUREAD_CLIENT_SECRET: process.env.AZUREAD_CLIENT_SECRET,
|
||||
AZUREAD_TENANT_ID: process.env.AZUREAD_TENANT_ID,
|
||||
|
||||
@@ -56,9 +56,6 @@
|
||||
"env": [
|
||||
"AIRTABLE_CLIENT_ID",
|
||||
"ASSET_PREFIX_URL",
|
||||
"AWS_ACCESS_KEY_ID",
|
||||
"AWS_SECRET_ACCESS_KEY",
|
||||
"AWS_REGION",
|
||||
"AZUREAD_CLIENT_ID",
|
||||
"AZUREAD_CLIENT_SECRET",
|
||||
"AZUREAD_TENANT_ID",
|
||||
|
||||
Reference in New Issue
Block a user