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; Endpoint?: string;
Key?: string; Key?: string;
Secret?: string; Secret?: string;
Token?: string;
Region?: string; Region?: string;
} }

View File

@ -16,6 +16,11 @@
[placeholder]="isAzure ? 'Shared access signature (SAS)' : 'Secret'"> [placeholder]="isAzure ? 'Shared access signature (SAS)' : 'Secret'">
<mat-error *ngIf="secretInput.errors?.required">*Required</mat-error> <mat-error *ngIf="secretInput.errors?.required">*Required</mat-error>
</mat-form-field> </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-form-field *ngIf="!isAzure" class="w-100">
<mat-label>Region</mat-label> <mat-label>Region</mat-label>
<input matInput [(ngModel)]="S3Form.Region" type="text" name="Region" placeholder="AWS Region (e.g. us-east-2)" <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() key;
@Input() secret = ''; @Input() secret = '';
@Input() region = ''; @Input() region = '';
@Input() token = '';
@Input() bucket; @Input() bucket;
@Input() endpoint; @Input() endpoint;
@Input() editMode = false; @Input() editMode = false;
@ -36,6 +37,7 @@ export class S3AccessDialogComponent implements OnChanges {
this.S3Form= { this.S3Form= {
Key : changes.isAzure.currentValue ? 'azure' : changes.key.currentValue, Key : changes.isAzure.currentValue ? 'azure' : changes.key.currentValue,
Secret : changes.secret.currentValue, Secret : changes.secret.currentValue,
Token : changes.token.currentValue,
Region : changes.region.currentValue, Region : changes.region.currentValue,
Bucket : changes.bucket.currentValue, Bucket : changes.bucket.currentValue,
Endpoint: (changes.endpoint.currentValue === null || changes.endpoint.currentValue?.startsWith('http')) ? Endpoint: (changes.endpoint.currentValue === null || changes.endpoint.currentValue?.startsWith('http')) ?

View File

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

View File

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

View File

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

View File

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

View File

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