Allow the use of tokens for s3 access (#53)

Co-authored-by: @annaelee
This commit is contained in:
annaelee 2023-05-24 01:38:58 -05:00 committed by GitHub
parent e54d8ebb99
commit e449a6c436
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 19 additions and 2 deletions

View File

@ -19,6 +19,7 @@ export interface Credentials {
Endpoint?: string;
Key?: string;
Secret?: string;
Token?: string;
Region?: string;
}

View File

@ -16,6 +16,11 @@
[placeholder]="isAzure ? 'Shared access signature (SAS)' : 'Secret'">
<mat-error *ngIf="secretInput.errors?.required">*Required</mat-error>
</mat-form-field>
<mat-form-field *ngIf="!isAzure" class="w-100">
<mat-label>Token</mat-label>
<input matInput [(ngModel)]="S3Form.Token" type="text" name="Token" placeholder="Token" [(ngModel)]="S3Form.Token" #keyInput="ngModel"
autocomplete="off">
</mat-form-field>
<mat-form-field *ngIf="!isAzure" class="w-100">
<mat-label>Region</mat-label>
<input matInput [(ngModel)]="S3Form.Region" type="text" name="Region" placeholder="AWS Region (e.g. us-east-2)"

View File

@ -16,6 +16,7 @@ export class S3AccessDialogComponent implements OnChanges {
@Input() key;
@Input() secret = '';
@Input() region = '';
@Input() token = '';
@Input() bucket;
@Input() endpoint;
@Input() editMode = false;
@ -36,6 +37,7 @@ export class S3AccessDialogComponent implements OnChanges {
this.S3Form= {
Key : changes.isAzure.currentValue ? 'azure' : changes.key.currentValue,
Secret : changes.secret.currentValue,
Token : changes.token.currentValue,
Region : changes.region.currentValue,
Bucket : changes.bucket.currentValue,
Endpoint: (changes.endpoint.currentValue === null || changes.endpoint.currentValue?.startsWith('http')) ?

View File

@ -6,6 +6,7 @@
[region]="region"
[secret]="secret"
[key]="key"
[token]="token"
[editMode]="editMode"
[isAzure]="isAzure"
(closeSave)="saveS3Credentials($event)"

View File

@ -16,6 +16,7 @@ export class S3AccessResolverComponent {
endpoint: any;
key: any;
secret: any;
token: any;
region: any;
header: any;
editMode: any;
@ -32,6 +33,7 @@ export class S3AccessResolverComponent {
this.endpoint = s3Credentials.Endpoint;
this.key = s3Credentials.Key;
this.secret = s3Credentials.Secret;
this.token = s3Credentials.Token;
this.region = s3Credentials.Region;
this.isAzure = data.isAzure;
if (data.credentialsError) {

View File

@ -138,7 +138,8 @@ export class BaseAdminService {
region: set.Region || DEFAULT_REGION,
credentials: {
accessKeyId: set.Key,
secretAccessKey: set.Secret
secretAccessKey: set.Secret,
sessionToken: set.Token
},
...(set.Endpoint && {
endpoint: {

View File

@ -3,6 +3,7 @@
<div class="col-6">Bucket</div>
<div class="col-4">Key</div>
<div class="col-6">Secret / SAS</div>
<div class="col-6">Token</div>
<div class="col-2">AWS Region</div>
<div class="col-6">Host (Endpoint)</div>
</div>
@ -18,6 +19,9 @@
<div class="col-6">
<input matInput class="form-control" formControlName="Secret">
</div>
<div class="col-6">
<input matInput class="form-control" formControlName="Token">
</div>
<div class="col-2">
<input matInput class="form-control" formControlName="Region" placeholder="us-east-2">
</div>

View File

@ -37,10 +37,11 @@ export class S3AccessComponent implements OnDestroy, OnInit {
return this.S3Form.get(this.BUCKET_CREDENTIALS) as UntypedFormArray;
}
addBucket({Key = '', Secret = '', Region = '', Bucket = '', Endpoint = null} = {}) {
addBucket({Key = '', Secret = '', Token='', Region = '', Bucket = '', Endpoint = null} = {}) {
this.bucketCredentials.push(this.formBuilder.group({
Key,
Secret,
Token,
Region,
Bucket,
Endpoint: (Endpoint?.startsWith('http') || Endpoint === null)? Endpoint : `http${Endpoint?.endsWith('443') ? 's' : ''}://${Endpoint}`