mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 15:00:57 +03:00
Feature: Support role-based authentication for AWS (#2470)
* Storage, DynamoDBChatMemory - Make AWS credentials optional to support role-based authentication * Lint fix
This commit is contained in:
@@ -1,6 +1,13 @@
|
||||
import path from 'path'
|
||||
import fs from 'fs'
|
||||
import { DeleteObjectsCommand, GetObjectCommand, ListObjectsV2Command, PutObjectCommand, S3Client } from '@aws-sdk/client-s3'
|
||||
import {
|
||||
DeleteObjectsCommand,
|
||||
GetObjectCommand,
|
||||
ListObjectsV2Command,
|
||||
PutObjectCommand,
|
||||
S3Client,
|
||||
S3ClientConfig
|
||||
} from '@aws-sdk/client-s3'
|
||||
import { Readable } from 'node:stream'
|
||||
import { getUserHome } from './utils'
|
||||
|
||||
@@ -311,14 +318,20 @@ export const getS3Config = () => {
|
||||
const secretAccessKey = process.env.S3_STORAGE_SECRET_ACCESS_KEY
|
||||
const region = process.env.S3_STORAGE_REGION
|
||||
const Bucket = process.env.S3_STORAGE_BUCKET_NAME
|
||||
if (!accessKeyId || !secretAccessKey || !region || !Bucket) {
|
||||
if (!region || !Bucket) {
|
||||
throw new Error('S3 storage configuration is missing')
|
||||
}
|
||||
const s3Client = new S3Client({
|
||||
credentials: {
|
||||
|
||||
let credentials: S3ClientConfig['credentials'] | undefined
|
||||
if (accessKeyId && secretAccessKey) {
|
||||
credentials = {
|
||||
accessKeyId,
|
||||
secretAccessKey
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
const s3Client = new S3Client({
|
||||
credentials,
|
||||
region
|
||||
})
|
||||
return { s3Client, Bucket }
|
||||
|
||||
Reference in New Issue
Block a user