Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated version of #128 #143

Merged
merged 3 commits into from
Sep 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions libs/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ export type BasicAuthConfiguration = { type: 'basic' } & (
export type AuthConfiguration = { type: 'none' } | BasicAuthConfiguration;

export interface S3StoreConfiguration {
accessKey: string;
secretKey: string;
detectCredentials: boolean;
accessKey?: string;
secretKey?: string;
bucket: string;
endpoint: string;
region: string;
Expand Down Expand Up @@ -93,16 +94,17 @@ export function loadConfig() {
}
// for now, this works
{
store.detectCredentials ??= true;
store.accessKey = getEnv<string>(
'STORE_ACCESS_KEY',
store.accessKey,
!store.accessKey
).toString();
!store.detectCredentials
)?.toString();
store.secretKey = getEnv<string>(
'STORE_SECRET_KEY',
store.secretKey,
!store.secretKey
).toString();
!store.detectCredentials
)?.toString();
store.bucket = getEnv<string>(
'STORE_BUCKET',
store.bucket ?? 'notea',
Expand Down
7 changes: 5 additions & 2 deletions libs/server/store/providers/s3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,14 @@ export class StoreS3 extends StoreProvider {
forcePathStyle: config.pathStyle,
region: config.region,
endpoint: config.endPoint,
credentials: {
credentials: ((config.accessKey && config.secretKey) ? {
accessKeyId: config.accessKey,
secretAccessKey: config.secretKey,
},
} : undefined),
});
if (!config.accessKey || !config.secretKey) {
console.log('[Notea] Environment variables STORE_ACCESS_KEY or STORE_SECRET_KEY is missing. Trying to use IAM role credentials instead ...');
}
this.config = config;
}

Expand Down