Skip to content

Commit

Permalink
Merge pull request #8 from alkem-io/develop
Browse files Browse the repository at this point in the history
authentication through header (#7)
  • Loading branch information
valentinyanakiev authored Jun 5, 2024
2 parents 46878ca + ced17f1 commit d3a5e8f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "file-service",
"version": "0.0.4",
"version": "0.1.0",
"description": "A file serving microservice for the Alkemio platform",
"main": "main.ts",
"scripts": {
Expand Down
20 changes: 13 additions & 7 deletions src/services/file-reader/file.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,20 @@ import { Readable } from 'stream';
import { ConfigService } from '@nestjs/config';
import { ConfigType } from '../../config';
import { pathResolve } from '../../core/utils/files';
import { Inject, Injectable, LoggerService, StreamableFile } from '@nestjs/common';
import {
Inject,
Injectable,
LoggerService,
StreamableFile,
} from '@nestjs/common';
import { FileAdapterService } from './file.adapter.service';
import { FileInfoInputData } from './inputs';
import { FileInfoOutputData, isFileInfoOutputWithErrorData } from './outputs';
import { FileInfoException, FileReadException, LocalStorageReadFailedException } from './exceptions';
import {
FileInfoException,
FileReadException,
LocalStorageReadFailedException,
} from './exceptions';
import { DocumentData } from './types';
import { WINSTON_MODULE_NEST_PROVIDER } from 'nest-winston';

Expand Down Expand Up @@ -38,14 +47,12 @@ export class FileService {
auth: {
cookie?: string;
authorization?: string;
apiToken?: string;
},
): Promise<FileInfoOutputData> {
const cookie = auth.cookie;
const apiToken = auth?.apiToken ?? auth?.authorization?.split(' ')?.[1];
const { cookie, authorization } = auth;

return this.adapter.fileInfo(
new FileInfoInputData(docId, { cookie, apiToken }),
new FileInfoInputData(docId, { cookie, authorization }),
);
}

Expand All @@ -62,7 +69,6 @@ export class FileService {
auth: {
cookie?: string;
authorization?: string;
apiToken?: string;
},
): Promise<DocumentData | never> {
const { data } = await this.fileInfo(docId, auth);
Expand Down
2 changes: 1 addition & 1 deletion src/services/file-reader/inputs/file.info.input.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export class FileInfoInputData extends BaseInputData {
public docId: string,
public auth: {
cookie?: string;
apiToken?: string;
authorization?: string;
},
) {
super('file-info-input');
Expand Down

0 comments on commit d3a5e8f

Please sign in to comment.