Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
feat: added options to disable authentication and set user info
Browse files Browse the repository at this point in the history
  • Loading branch information
dkrantsberg committed Apr 8, 2020
1 parent bc4dcef commit 6a017b5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/loopback-proxy-app/sequence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// License text available at https://opensource.org/licenses/MIT

import {Context, inject} from '@loopback/context';
import {ApplicationConfig, CoreBindings} from '@loopback/core';
import {FindRoute, InvokeMethod, ParseParams, Reject, RequestContext, RestBindings, Send, SequenceHandler} from '@loopback/rest';
import {LabShareLogger, LogBindings} from '@labshare/services-logger';
import {AuthenticateFn, AuthenticationBindings} from '@labshare/services-auth';
Expand All @@ -20,6 +21,8 @@ export class LabShareSequence implements SequenceHandler {
@inject(SequenceActions.REJECT) public reject: Reject,
@inject(LogBindings.LOGGER) protected logger: LabShareLogger,
@inject(AuthenticationBindings.AUTH_ACTION) protected authenticateRequest: AuthenticateFn,
@inject(AuthenticationBindings.USER_INFO_ACTION) protected setUserInfo: AuthenticateFn,
@inject(CoreBindings.APPLICATION_CONFIG) protected config: ApplicationConfig
) {}

async handle(context: RequestContext) {
Expand All @@ -29,7 +32,12 @@ export class LabShareSequence implements SequenceHandler {
const route = this.findRoute(request);
request.params = route.pathParams;
const args = await this.parseParams(request, route);
await this.authenticateRequest(request, response);
if (!this.config?.services?.auth?.disable && !process.env.DISABLE_AUTH) {
await this.authenticateRequest(request, response);
}
if (this.config?.services?.auth?.setUserInfo) {
await this.setUserInfo(request, response);
}
const result = await this.invoke(route, args);
this.send(response, result);
} catch (error) {
Expand Down

0 comments on commit 6a017b5

Please sign in to comment.