Skip to content

TagSpaces is an offline, open source, document manager with tagging support

add optional sessionToken parameter to AWS.S3 (#1363)

Stanimir26fecad260e5
diff --git a/app/components/dialogs/CreateEditLocationDialog.tsx b/app/components/dialogs/CreateEditLocationDialog.tsx
index 5901da191..6abfac94d 100644
--- a/app/components/dialogs/CreateEditLocationDialog.tsx
+++ b/app/components/dialogs/CreateEditLocationDialog.tsx
@@ -112,6 +112,9 @@ const CreateEditLocationDialog = (props: Props) => {
const [secretAccessKey, setSecretAccessKey] = useState<string>(
location ? location.secretAccessKey : ''
);
+ const [sessionToken, setSessionToken] = useState<string>(
+ location ? location.sessionToken : undefined
+ );
const [bucketName, setBucketName] = useState<string>(
location ? location.bucketName : ''
);
@@ -236,6 +239,7 @@ const CreateEditLocationDialog = (props: Props) => {
endpointURL,
accessKeyId,
secretAccessKey,
+ sessionToken,
bucketName,
region,
isDefault,
@@ -276,6 +280,7 @@ const CreateEditLocationDialog = (props: Props) => {
storePath={storePath}
accessKeyId={accessKeyId}
secretAccessKey={secretAccessKey}
+ sessionToken={sessionToken}
setShowSecretAccessKey={setShowSecretAccessKey}
bucketName={bucketName}
region={region}
@@ -285,6 +290,7 @@ const CreateEditLocationDialog = (props: Props) => {
setStorePath={setStorePath}
setAccessKeyId={setAccessKeyId}
setSecretAccessKey={setSecretAccessKey}
+ setSessionToken={setSessionToken}
setBucketName={setBucketName}
setEndpointURL={setEndpointURL}
setNewUuid={setNewUuid}
diff --git a/app/components/dialogs/ObjectStoreForm.tsx b/app/components/dialogs/ObjectStoreForm.tsx
index 2dc4ce80e..751a62f53 100644
--- a/app/components/dialogs/ObjectStoreForm.tsx
+++ b/app/components/dialogs/ObjectStoreForm.tsx
@@ -136,6 +136,7 @@ interface Props {
storePath: string;
accessKeyId: string;
secretAccessKey: string;
+ sessionToken: string;
bucketName: string;
region: string;
endpointURL: string;
@@ -144,6 +145,7 @@ interface Props {
setStorePath: (string) => void;
setAccessKeyId: (string) => void;
setSecretAccessKey: (string) => void;
+ setSessionToken: (string) => void;
setShowSecretAccessKey: (boolean) => void;
setBucketName: (string) => void;
setRegion: (string) => void;
@@ -166,6 +168,7 @@ const ObjectStoreForm = (props: Props) => {
storePath,
accessKeyId,
secretAccessKey,
+ sessionToken,
bucketName,
region,
endpointURL,
@@ -174,6 +177,7 @@ const ObjectStoreForm = (props: Props) => {
setStorePath,
setAccessKeyId,
setSecretAccessKey,
+ setSessionToken,
setBucketName,
setEndpointURL,
setNewUuid,
@@ -284,6 +288,24 @@ const ObjectStoreForm = (props: Props) => {
)} */}
</FormControl>
</Grid>
+ {showAdvancedMode && (
+ <Grid item xs={12}>
+ <FormControl fullWidth={true}>
+ <InputLabel htmlFor="sessionToken">
+ {i18n.t('core:sessionToken')}
+ </InputLabel>
+ <Input
+ margin="dense"
+ name="sessionToken"
+ fullWidth={true}
+ data-tid="sessionTokenTID"
+ inputProps={{ autoCorrect: 'off', autoCapitalize: 'none' }}
+ onChange={event => setSessionToken(event.target.value)}
+ value={sessionToken}
+ />
+ </FormControl>
+ </Grid>
+ )}
<Grid item xs={12}>
<FormControl fullWidth={true} error={cloudErrorBucketName}>
<InputLabel htmlFor="bucketName">
diff --git a/app/reducers/locations.ts b/app/reducers/locations.ts
index cb803be78..cc39fc35b 100644
--- a/app/reducers/locations.ts
+++ b/app/reducers/locations.ts
@@ -44,6 +44,7 @@ export type Location = {
type: string;
accessKeyId?: string;
secretAccessKey?: string;
+ sessionToken?: string;
bucketName?: string;
region?: string;
paths?: Array<string>; // deprecated
diff --git a/app/services/objectstore-io.ts b/app/services/objectstore-io.ts
index 28cd53243..e0e430123 100644
--- a/app/services/objectstore-io.ts
+++ b/app/services/objectstore-io.ts
@@ -50,6 +50,7 @@ export default class ObjectStoreIO {
endpoint: endpoint as string,
accessKeyId: this.config.accessKeyId,
secretAccessKey: this.config.secretAccessKey,
+ sessionToken: this.config.sessionToken,
s3ForcePathStyle: true, // needed for minio
signatureVersion: 'v4', // needed for minio
logger: console