Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
);
}
}
// the JWT_secret to encrypt and decrypt JWT token
export const JWT_SECRET = 'changeme';
// the required interface to filter login payload
export interface Credentials {
username: string;
password: string;
}
// implement custom namespace bindings
export namespace MyAuthBindings {
export const STRATEGY = BindingKey.create('authentication.strategy');
}
// the strategy provider will parse the specifed strategy, and act accordingly
export class MyAuthAuthenticationStrategyProvider implements Provider {
constructor(
@inject(AuthenticationBindings.METADATA) private metadata: MyAuthenticationMetadata,
@repository(UserRepository) private userRepository: UserRepository,
@repository(UserRoleRepository) private userRoleRepository: UserRoleRepository,
) {}
value(): ValueOrPromise {
if (!this.metadata) return;
const {strategy} = this.metadata;
if (strategy === JWT_STRATEGY_NAME) {
const jwtStrategy = new JwtStrategy(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const FLUENT_SENDER = BindingKey.create>(
'logging.fluent.sender',
);
/**
* Binding key for winston logger
*/
export const WINSTON_LOGGER = BindingKey.create(
'logging.winston.logger',
);
/**
* Binding key for winston transport backed by fluent
*/
export const WINSTON_TRANSPORT_FLUENT = BindingKey.create(
'logging.winston.transports.fluent',
);
/**
* Binding key for method invocation logger with winston
*/
export const WINSTON_INVOCATION_LOGGER = BindingKey.create<
GenericInterceptor
>('logging.winston.invocationLogger');
/**
* Binding key for http access logger with winston
*/
export const WINSTON_HTTP_ACCESS_LOGGER = BindingKey.create<
GenericInterceptor
>('logging.winston.httpAccessLogger');
import {BindingKey, GenericInterceptor} from '@loopback/core';
import {FluentSender} from 'fluent-logger';
import * as WinstonTransport from 'winston-transport';
import {LoggingComponent} from './logging.component';
import {WinstonLogger} from './winston';
/**
* Binding keys used by this component.
*/
export namespace LoggingBindings {
export const COMPONENT = BindingKey.create(
'components.LoggingComponent',
);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const FLUENT_SENDER = BindingKey.create>(
'logging.fluent.sender',
);
/**
* Binding key for winston logger
*/
export const WINSTON_LOGGER = BindingKey.create(
'logging.winston.logger',
);
/**
* Binding key for winston transport backed by fluent
*/
export const WINSTON_TRANSPORT_FLUENT = BindingKey.create(
'logging.winston.transports.fluent',
);
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
import {BindingKey, CoreBindings} from '@loopback/core';
import {AuthorizationComponent} from './authorization-component';
import {AuthorizationMetadata} from './types';
/**
* Binding keys used by authorization component.
*/
export namespace AuthorizationBindings {
export const METADATA = BindingKey.create(
'authorization.operationMetadata',
);
export const COMPONENT = BindingKey.create(
`${CoreBindings.COMPONENTS}.AuthorizationComponent`,
);
}
/**
* Binding tags used by authorization component
*/
export namespace AuthorizationTags {
/**
* A tag for authorizers
*/
export const AUTHORIZER = 'authorizer';
}
* Binding keys used by this component.
*/
export namespace LoggingBindings {
export const COMPONENT = BindingKey.create(
'components.LoggingComponent',
);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const FLUENT_SENDER = BindingKey.create>(
'logging.fluent.sender',
);
/**
* Binding key for winston logger
*/
export const WINSTON_LOGGER = BindingKey.create(
'logging.winston.logger',
);
/**
* Binding key for winston transport backed by fluent
*/
export const WINSTON_TRANSPORT_FLUENT = BindingKey.create(
'logging.winston.transports.fluent',
);
/**
* Binding key for method invocation logger with winston
*/
export const WINSTON_INVOCATION_LOGGER = BindingKey.create<
GenericInterceptor
>('logging.winston.invocationLogger');
// Copyright IBM Corp. 2018. All Rights Reserved.
// Node module: @loopback/authorization
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
import {BindingKey, CoreBindings} from '@loopback/core';
import {AuthorizationComponent} from './authorization-component';
import {AuthorizationMetadata} from './types';
/**
* Binding keys used by authorization component.
*/
export namespace AuthorizationBindings {
export const METADATA = BindingKey.create(
'authorization.operationMetadata',
);
export const COMPONENT = BindingKey.create(
`${CoreBindings.COMPONENTS}.AuthorizationComponent`,
);
}
/**
* Binding tags used by authorization component
*/
export namespace AuthorizationTags {
/**
* A tag for authorizers
*/
export const AUTHORIZER = 'authorizer';
// Copyright IBM Corp. 2019. All Rights Reserved.
// Node module: @loopback/extension-logging
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
import {BindingKey, GenericInterceptor} from '@loopback/core';
import {FluentSender} from 'fluent-logger';
import * as WinstonTransport from 'winston-transport';
import {LoggingComponent} from './logging.component';
import {WinstonLogger} from './winston';
/**
* Binding keys used by this component.
*/
export namespace LoggingBindings {
export const COMPONENT = BindingKey.create(
'components.LoggingComponent',
);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const FLUENT_SENDER = BindingKey.create>(
'logging.fluent.sender',
);
/**
* Binding key for winston logger
*/
export const WINSTON_LOGGER = BindingKey.create(
'logging.winston.logger',
);
/**
*/
export const WINSTON_TRANSPORT_FLUENT = BindingKey.create(
'logging.winston.transports.fluent',
);
/**
* Binding key for method invocation logger with winston
*/
export const WINSTON_INVOCATION_LOGGER = BindingKey.create<
GenericInterceptor
>('logging.winston.invocationLogger');
/**
* Binding key for http access logger with winston
*/
export const WINSTON_HTTP_ACCESS_LOGGER = BindingKey.create<
GenericInterceptor
>('logging.winston.httpAccessLogger');
}
import {
AuthorizationComponent,
AuthorizationTags,
} from '@loopback/authorization';
import {createEnforcer} from './services/enforcer';
import {CasbinAuthorizationProvider} from './services/authorizor';
/**
* Information from package.json
*/
export interface PackageInfo {
name: string;
version: string;
description: string;
}
export const PackageKey = BindingKey.create('application.package');
const pkg: PackageInfo = require('../package.json');
export class ShoppingApplication extends BootMixin(
ServiceMixin(RepositoryMixin(RestApplication)),
) {
constructor(options?: ApplicationConfig) {
super(options);
/*
This is a workaround until an extension point is introduced
allowing extensions to contribute to the OpenAPI specification
dynamically.
*/
this.api({
openapi: '3.0.0',
*/
export const WINSTON_LOGGER = BindingKey.create(
'logging.winston.logger',
);
/**
* Binding key for winston transport backed by fluent
*/
export const WINSTON_TRANSPORT_FLUENT = BindingKey.create(
'logging.winston.transports.fluent',
);
/**
* Binding key for method invocation logger with winston
*/
export const WINSTON_INVOCATION_LOGGER = BindingKey.create<
GenericInterceptor
>('logging.winston.invocationLogger');
/**
* Binding key for http access logger with winston
*/
export const WINSTON_HTTP_ACCESS_LOGGER = BindingKey.create<
GenericInterceptor
>('logging.winston.httpAccessLogger');
}