@loopback/authentication 2.2.0 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,17 +3,6 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- # [2.2.0](https://github.com/strongloop/loopback-next/compare/@loopback/authentication@2.1.11...@loopback/authentication@2.2.0) (2019-09-03)
7
-
8
-
9
- ### Features
10
-
11
- * **authentication:** allow AuthenticationStrategyProvider to get extended ([c88a424](https://github.com/strongloop/loopback-next/commit/c88a424))
12
-
13
-
14
-
15
-
16
-
17
6
  ## [2.1.11](https://github.com/strongloop/loopback-next/compare/@loopback/authentication@2.1.10...@loopback/authentication@2.1.11) (2019-08-19)
18
7
 
19
8
  **Note:** Version bump only for package @loopback/authentication
@@ -16,7 +16,7 @@ function authenticate(strategyName, options) {
16
16
  return context_1.MethodDecoratorFactory.createDecorator(keys_1.AUTHENTICATION_METADATA_KEY, {
17
17
  strategy: strategyName,
18
18
  options: options || {},
19
- }, { decoratorName: '@authenticate' });
19
+ });
20
20
  }
21
21
  exports.authenticate = authenticate;
22
22
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"authenticate.decorator.js","sourceRoot":"","sources":["../../src/decorators/authenticate.decorator.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,wCAAwC;AACxC,+CAA+C;AAC/C,gEAAgE;;AAEhE,+CAI2B;AAC3B,kCAAoD;AAUpD;;;;;GAKG;AACH,SAAgB,YAAY,CAAC,YAAoB,EAAE,OAAgB;IACjE,OAAO,gCAAsB,CAAC,eAAe,CAC3C,kCAA2B,EAC3B;QACE,QAAQ,EAAE,YAAY;QACtB,OAAO,EAAE,OAAO,IAAI,EAAE;KACvB,EACD,EAAC,aAAa,EAAE,eAAe,EAAC,CACjC,CAAC;AACJ,CAAC;AATD,oCASC;AAED;;;;;GAKG;AACH,SAAgB,uBAAuB,CACrC,eAAgC,EAChC,UAAkB;IAElB,OAAO,2BAAiB,CAAC,iBAAiB,CACxC,kCAA2B,EAC3B,eAAe,CAAC,SAAS,EACzB,UAAU,CACX,CAAC;AACJ,CAAC;AATD,0DASC"}
1
+ {"version":3,"file":"authenticate.decorator.js","sourceRoot":"","sources":["../../src/decorators/authenticate.decorator.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,wCAAwC;AACxC,+CAA+C;AAC/C,gEAAgE;;AAEhE,+CAI2B;AAC3B,kCAAoD;AAUpD;;;;;GAKG;AACH,SAAgB,YAAY,CAAC,YAAoB,EAAE,OAAgB;IACjE,OAAO,gCAAsB,CAAC,eAAe,CAC3C,kCAA2B,EAC3B;QACE,QAAQ,EAAE,YAAY;QACtB,OAAO,EAAE,OAAO,IAAI,EAAE;KACvB,CACF,CAAC;AACJ,CAAC;AARD,oCAQC;AAED;;;;;GAKG;AACH,SAAgB,uBAAuB,CACrC,eAAgC,EAChC,UAAkB;IAElB,OAAO,2BAAiB,CAAC,iBAAiB,CACxC,kCAA2B,EAC3B,eAAe,CAAC,SAAS,EACzB,UAAU,CACX,CAAC;AACJ,CAAC;AATD,0DASC"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  export * from './authentication.component';
2
2
  export * from './decorators';
3
3
  export * from './keys';
4
- export * from './providers';
5
4
  export * from './services';
6
5
  export * from './types';
package/dist/index.js CHANGED
@@ -10,6 +10,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  __export(require("./authentication.component"));
11
11
  __export(require("./decorators"));
12
12
  __export(require("./keys"));
13
- __export(require("./providers"));
14
13
  __export(require("./types"));
15
14
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,wCAAwC;AACxC,+CAA+C;AAC/C,gEAAgE;;;;;AAEhE,gDAA2C;AAC3C,kCAA6B;AAC7B,4BAAuB;AACvB,iCAA4B;AAE5B,6BAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,wCAAwC;AACxC,+CAA+C;AAC/C,gEAAgE;;;;;AAEhE,gDAA2C;AAC3C,kCAA6B;AAC7B,4BAAuB;AAEvB,6BAAwB"}
package/dist/keys.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { BindingKey } from '@loopback/context';
2
2
  import { MetadataAccessor } from '@loopback/metadata';
3
3
  import { AuthenticationMetadata } from './decorators';
4
- import { AuthenticateFn, AuthenticationStrategy } from './types';
4
+ import { AuthenticateFn, AuthenticationStrategy, UserProfile } from './types';
5
5
  /**
6
6
  * Binding keys used by this component.
7
7
  */
@@ -71,8 +71,23 @@ export declare namespace AuthenticationBindings {
71
71
  * ```
72
72
  */
73
73
  const METADATA: BindingKey<AuthenticationMetadata | undefined>;
74
+ /**
75
+ * Key used to inject the user instance retrieved by the
76
+ * authentication function
77
+ *
78
+ * @example
79
+ * ```ts
80
+ * class MyController {
81
+ * constructor(
82
+ * @inject(AuthenticationBindings.CURRENT_USER) private user: UserProfile,
83
+ * ) {}
84
+ *
85
+ * // ... routes that may need authentication
86
+ * ```
87
+ * }
88
+ */
89
+ const CURRENT_USER: BindingKey<UserProfile | undefined>;
74
90
  const AUTHENTICATION_STRATEGY_EXTENSION_POINT_NAME = "authentication.strategies";
75
- const CURRENT_USER: BindingKey<import("@loopback/security").UserProfile>;
76
91
  }
77
92
  /**
78
93
  * The key used to store log-related via @loopback/metadata and reflection.
package/dist/keys.js CHANGED
@@ -6,7 +6,6 @@
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  const context_1 = require("@loopback/context");
8
8
  const metadata_1 = require("@loopback/metadata");
9
- const security_1 = require("@loopback/security");
10
9
  /**
11
10
  * Binding keys used by this component.
12
11
  */
@@ -77,9 +76,23 @@ var AuthenticationBindings;
77
76
  * ```
78
77
  */
79
78
  AuthenticationBindings.METADATA = context_1.BindingKey.create('authentication.operationMetadata');
79
+ /**
80
+ * Key used to inject the user instance retrieved by the
81
+ * authentication function
82
+ *
83
+ * @example
84
+ * ```ts
85
+ * class MyController {
86
+ * constructor(
87
+ * @inject(AuthenticationBindings.CURRENT_USER) private user: UserProfile,
88
+ * ) {}
89
+ *
90
+ * // ... routes that may need authentication
91
+ * ```
92
+ * }
93
+ */
94
+ AuthenticationBindings.CURRENT_USER = context_1.BindingKey.create('authentication.currentUser');
80
95
  AuthenticationBindings.AUTHENTICATION_STRATEGY_EXTENSION_POINT_NAME = 'authentication.strategies';
81
- // Make `CURRENT_USER` the alias of the security bindings
82
- AuthenticationBindings.CURRENT_USER = security_1.SecurityBindings.USER;
83
96
  })(AuthenticationBindings = exports.AuthenticationBindings || (exports.AuthenticationBindings = {}));
84
97
  /**
85
98
  * The key used to store log-related via @loopback/metadata and reflection.
package/dist/keys.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"keys.js","sourceRoot":"","sources":["../src/keys.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,wCAAwC;AACxC,+CAA+C;AAC/C,gEAAgE;;AAEhE,+CAA6C;AAC7C,iDAAoD;AACpD,iDAAoD;AAIpD;;GAEG;AACH,IAAiB,sBAAsB,CAgFtC;AAhFD,WAAiB,sBAAsB;IACrC;;;;;;;;;;OAUG;IACU,+BAAQ,GAAG,oBAAU,CAAC,MAAM,CACvC,yBAAyB,CAC1B,CAAC;IAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACU,kCAAW,GAAG,oBAAU,CAAC,MAAM,CAC1C,qCAAqC,CACtC,CAAC;IAEF;;;;;;;;;;;;;;;;;;;OAmBG;IACU,+BAAQ,GAAG,oBAAU,CAAC,MAAM,CACvC,kCAAkC,CACnC,CAAC;IAEW,mEAA4C,GACvD,2BAA2B,CAAC;IAE9B,yDAAyD;IAC5C,mCAAY,GAAG,2BAAgB,CAAC,IAAI,CAAC;AACpD,CAAC,EAhFgB,sBAAsB,GAAtB,8BAAsB,KAAtB,8BAAsB,QAgFtC;AAED;;GAEG;AACU,QAAA,2BAA2B,GAAG,2BAAgB,CAAC,MAAM,CAGhE,mCAAmC,CAAC,CAAC"}
1
+ {"version":3,"file":"keys.js","sourceRoot":"","sources":["../src/keys.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,wCAAwC;AACxC,+CAA+C;AAC/C,gEAAgE;;AAEhE,+CAA6C;AAC7C,iDAAoD;AAIpD;;GAEG;AACH,IAAiB,sBAAsB,CAgGtC;AAhGD,WAAiB,sBAAsB;IACrC;;;;;;;;;;OAUG;IACU,+BAAQ,GAAG,oBAAU,CAAC,MAAM,CACvC,yBAAyB,CAC1B,CAAC;IAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACU,kCAAW,GAAG,oBAAU,CAAC,MAAM,CAC1C,qCAAqC,CACtC,CAAC;IAEF;;;;;;;;;;;;;;;;;;;OAmBG;IACU,+BAAQ,GAAG,oBAAU,CAAC,MAAM,CACvC,kCAAkC,CACnC,CAAC;IAEF;;;;;;;;;;;;;;OAcG;IACU,mCAAY,GAAG,oBAAU,CAAC,MAAM,CAC3C,4BAA4B,CAC7B,CAAC;IAEW,mEAA4C,GACvD,2BAA2B,CAAC;AAChC,CAAC,EAhGgB,sBAAsB,GAAtB,8BAAsB,KAAtB,8BAAsB,QAgGtC;AAED;;GAEG;AACU,QAAA,2BAA2B,GAAG,2BAAgB,CAAC,MAAM,CAGhE,mCAAmC,CAAC,CAAC"}
@@ -1,7 +1,6 @@
1
1
  import { Getter, Provider, Setter } from '@loopback/context';
2
2
  import { Request } from '@loopback/rest';
3
- import { UserProfile } from '@loopback/security';
4
- import { AuthenticateFn, AuthenticationStrategy } from '../types';
3
+ import { AuthenticateFn, AuthenticationStrategy, UserProfile } from '../types';
5
4
  /**
6
5
  * Provides the authentication action for a sequence
7
6
  * @example `context.bind('authentication.actions.authenticate').toProvider(AuthenticateActionProvider)`
@@ -17,7 +17,6 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
17
17
  };
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  const context_1 = require("@loopback/context");
20
- const security_1 = require("@loopback/security");
21
20
  const keys_1 = require("../keys");
22
21
  const types_1 = require("../types");
23
22
  /**
@@ -68,7 +67,7 @@ let AuthenticateActionProvider = class AuthenticateActionProvider {
68
67
  };
69
68
  AuthenticateActionProvider = __decorate([
70
69
  __param(0, context_1.inject.getter(keys_1.AuthenticationBindings.STRATEGY)),
71
- __param(1, context_1.inject.setter(security_1.SecurityBindings.USER)),
70
+ __param(1, context_1.inject.setter(keys_1.AuthenticationBindings.CURRENT_USER)),
72
71
  __metadata("design:paramtypes", [Function, Function])
73
72
  ], AuthenticateActionProvider);
74
73
  exports.AuthenticateActionProvider = AuthenticateActionProvider;
@@ -1 +1 @@
1
- {"version":3,"file":"auth-action.provider.js","sourceRoot":"","sources":["../../src/providers/auth-action.provider.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,wCAAwC;AACxC,+CAA+C;AAC/C,gEAAgE;;;;;;;;;;;;;;AAEhE,+CAAmE;AAEnE,iDAAiE;AACjE,kCAA+C;AAC/C,oCAIkB;AAClB;;;GAGG;AACH,IAAa,0BAA0B,GAAvC,MAAa,0BAA0B;IACrC;IACE,yDAAyD;IACzD,4DAA4D;IAC5D,qDAAqD;IACrD,qCAAqC;IACrC,8DAA8D;IAC9D,+DAA+D;IAC/D,eAAe;IAEN,WAA2C,EAE3C,cAAmC;QAFnC,gBAAW,GAAX,WAAW,CAAgC;QAE3C,mBAAc,GAAd,cAAc,CAAqB;IAC3C,CAAC;IAEJ;;OAEG;IACH,KAAK;QACH,OAAO,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,MAAM,CAAC,OAAgB;QAC3B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC;QAC1C,IAAI,CAAC,QAAQ,EAAE;YACb,yDAAyD;YACzD,OAAO,SAAS,CAAC;SAClB;QAED,MAAM,WAAW,GAAG,MAAM,QAAQ,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QACzD,IAAI,CAAC,WAAW,EAAE;YAChB,wDAAwD;YACxD,MAAM,KAAK,GAAG,IAAI,KAAK,CACrB,iEAAiE,CAClE,CAAC;YACF,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE;gBACnB,IAAI,EAAE,8BAAsB;aAC7B,CAAC,CAAC;YACH,MAAM,KAAK,CAAC;SACb;QAED,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;QACjC,OAAO,WAAW,CAAC;IACrB,CAAC;CACF,CAAA;AAhDY,0BAA0B;IASlC,WAAA,gBAAM,CAAC,MAAM,CAAC,6BAAsB,CAAC,QAAQ,CAAC,CAAA;IAE9C,WAAA,gBAAM,CAAC,MAAM,CAAC,2BAAgB,CAAC,IAAI,CAAC,CAAA;;GAX5B,0BAA0B,CAgDtC;AAhDY,gEAA0B"}
1
+ {"version":3,"file":"auth-action.provider.js","sourceRoot":"","sources":["../../src/providers/auth-action.provider.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,wCAAwC;AACxC,+CAA+C;AAC/C,gEAAgE;;;;;;;;;;;;;;AAEhE,+CAAmE;AAEnE,kCAA+C;AAC/C,oCAKkB;AAClB;;;GAGG;AACH,IAAa,0BAA0B,GAAvC,MAAa,0BAA0B;IACrC;IACE,yDAAyD;IACzD,4DAA4D;IAC5D,qDAAqD;IACrD,qCAAqC;IACrC,8DAA8D;IAC9D,+DAA+D;IAC/D,eAAe;IAEN,WAA2C,EAE3C,cAAmC;QAFnC,gBAAW,GAAX,WAAW,CAAgC;QAE3C,mBAAc,GAAd,cAAc,CAAqB;IAC3C,CAAC;IAEJ;;OAEG;IACH,KAAK;QACH,OAAO,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,MAAM,CAAC,OAAgB;QAC3B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC;QAC1C,IAAI,CAAC,QAAQ,EAAE;YACb,yDAAyD;YACzD,OAAO,SAAS,CAAC;SAClB;QAED,MAAM,WAAW,GAAG,MAAM,QAAQ,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QACzD,IAAI,CAAC,WAAW,EAAE;YAChB,wDAAwD;YACxD,MAAM,KAAK,GAAG,IAAI,KAAK,CACrB,iEAAiE,CAClE,CAAC;YACF,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE;gBACnB,IAAI,EAAE,8BAAsB;aAC7B,CAAC,CAAC;YACH,MAAM,KAAK,CAAC;SACb;QAED,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;QACjC,OAAO,WAAW,CAAC;IACrB,CAAC;CACF,CAAA;AAhDY,0BAA0B;IASlC,WAAA,gBAAM,CAAC,MAAM,CAAC,6BAAsB,CAAC,QAAQ,CAAC,CAAA;IAE9C,WAAA,gBAAM,CAAC,MAAM,CAAC,6BAAsB,CAAC,YAAY,CAAC,CAAA;;GAX1C,0BAA0B,CAgDtC;AAhDY,gEAA0B"}
@@ -12,8 +12,8 @@ import { AuthenticationStrategy } from '../types';
12
12
  * @example `context.bind('authentication.strategy').toProvider(AuthenticationStrategyProvider)`
13
13
  */
14
14
  export declare class AuthenticationStrategyProvider implements Provider<AuthenticationStrategy | undefined> {
15
- protected authenticationStrategies: Getter<AuthenticationStrategy[]>;
16
- protected metadata?: AuthenticationMetadata | undefined;
15
+ private authenticationStrategies;
16
+ private metadata?;
17
17
  constructor(authenticationStrategies: Getter<AuthenticationStrategy[]>, metadata?: AuthenticationMetadata | undefined);
18
18
  value(): Promise<AuthenticationStrategy | undefined>;
19
19
  findAuthenticationStrategy(name: string): Promise<AuthenticationStrategy | undefined>;
@@ -1 +1 @@
1
- {"version":3,"file":"auth-strategy.provider.js","sourceRoot":"","sources":["../../src/providers/auth-strategy.provider.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,wCAAwC;AACxC,+CAA+C;AAC/C,gEAAgE;;;;;;;;;;;;;;AAEhE,+CAA+D;AAC/D,yCAAoE;AAEpE,kCAA+C;AAC/C,oCAGkB;AAElB;;;;;;;;GAQG;AAKH,IAAa,8BAA8B,GAA3C,MAAa,8BAA8B;IAEzC,YAEY,wBAA0D,EAE1D,QAAiC;QAFjC,6BAAwB,GAAxB,wBAAwB,CAAkC;QAE1D,aAAQ,GAAR,QAAQ,CAAyB;IAC1C,CAAC;IACJ,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YAClB,OAAO,SAAS,CAAC;SAClB;QACD,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;QACpC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,CAAC;QAC7D,IAAI,CAAC,QAAQ,EAAE;YACb,wDAAwD;YACxD,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,iBAAiB,IAAI,qBAAqB,CAAC,CAAC;YACpE,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE;gBACnB,IAAI,EAAE,yCAAiC;aACxC,CAAC,CAAC;YACH,MAAM,KAAK,CAAC;SACb;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,0BAA0B,CAAC,IAAY;QAC3C,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,wBAAwB,EAAE,CAAC;QACzD,MAAM,oBAAoB,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;QACnE,OAAO,oBAAoB,CAAC;IAC9B,CAAC;CACF,CAAA;AA9BY,8BAA8B;IAJ1C,qBAAc,CACb,6BAAsB,CAAC,4CAA4C,EACnE,EAAC,KAAK,EAAE,sBAAY,CAAC,SAAS,EAAC,CAChC,CAAC,6DAA6D;;IAI1D,WAAA,iBAAU,EAAE,CAAA;IAEZ,WAAA,gBAAM,CAAC,6BAAsB,CAAC,QAAQ,CAAC,CAAA;;GAL/B,8BAA8B,CA8B1C;AA9BY,wEAA8B"}
1
+ {"version":3,"file":"auth-strategy.provider.js","sourceRoot":"","sources":["../../src/providers/auth-strategy.provider.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,wCAAwC;AACxC,+CAA+C;AAC/C,gEAAgE;;;;;;;;;;;;;;AAEhE,+CAA+D;AAC/D,yCAAoE;AAEpE,kCAA+C;AAC/C,oCAGkB;AAElB;;;;;;;;GAQG;AAKH,IAAa,8BAA8B,GAA3C,MAAa,8BAA8B;IAEzC,YAEU,wBAA0D,EAE1D,QAAiC;QAFjC,6BAAwB,GAAxB,wBAAwB,CAAkC;QAE1D,aAAQ,GAAR,QAAQ,CAAyB;IACxC,CAAC;IACJ,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YAClB,OAAO,SAAS,CAAC;SAClB;QACD,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;QACpC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,CAAC;QAC7D,IAAI,CAAC,QAAQ,EAAE;YACb,wDAAwD;YACxD,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,iBAAiB,IAAI,qBAAqB,CAAC,CAAC;YACpE,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE;gBACnB,IAAI,EAAE,yCAAiC;aACxC,CAAC,CAAC;YACH,MAAM,KAAK,CAAC;SACb;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,0BAA0B,CAAC,IAAY;QAC3C,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,wBAAwB,EAAE,CAAC;QACzD,MAAM,oBAAoB,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;QACnE,OAAO,oBAAoB,CAAC;IAC9B,CAAC;CACF,CAAA;AA9BY,8BAA8B;IAJ1C,qBAAc,CACb,6BAAsB,CAAC,4CAA4C,EACnE,EAAC,KAAK,EAAE,sBAAY,CAAC,SAAS,EAAC,CAChC,CAAC,6DAA6D;;IAI1D,WAAA,iBAAU,EAAE,CAAA;IAEZ,WAAA,gBAAM,CAAC,6BAAsB,CAAC,QAAQ,CAAC,CAAA;;GAL/B,8BAA8B,CA8B1C;AA9BY,wEAA8B"}
@@ -1,4 +1,4 @@
1
- import { UserProfile } from '@loopback/security';
1
+ import { UserProfile } from '../types';
2
2
  /**
3
3
  * An interface for generating and verifying a token
4
4
  */
@@ -1,4 +1,4 @@
1
- import { UserProfile } from '@loopback/security';
1
+ import { UserProfile } from '../types';
2
2
  /**
3
3
  * A service for performing the login action in an authentication strategy.
4
4
  *
package/dist/types.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { Constructor, Context } from '@loopback/core';
2
2
  import { Request } from '@loopback/rest';
3
- import { UserProfile } from '@loopback/security';
4
3
  /**
5
4
  * interface definition of a function which accepts a request
6
5
  * and returns an authenticated user
@@ -8,6 +7,15 @@ import { UserProfile } from '@loopback/security';
8
7
  export interface AuthenticateFn {
9
8
  (request: Request): Promise<UserProfile | undefined>;
10
9
  }
10
+ /**
11
+ * interface definition of a user profile
12
+ * http://openid.net/specs/openid-connect-core-1_0.html#StandardClaims
13
+ */
14
+ export interface UserProfile {
15
+ id: string;
16
+ name?: string;
17
+ email?: string;
18
+ }
11
19
  /**
12
20
  * An interface that describes the common authentication strategy.
13
21
  *
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,wCAAwC;AACxC,+CAA+C;AAC/C,gEAAgE;;AAEhE,yCAAkE;AAGlE,iCAA8C;AAuCjC,QAAA,iCAAiC,GAC5C,mCAAmC,CAAC;AAEzB,QAAA,sBAAsB,GAAG,wBAAwB,CAAC;AAE/D;;GAEG;AACH,SAAgB,8BAA8B,CAC5C,OAAgB,EAChB,aAAkD;IAElD,mBAAY,CACV,OAAO,EACP,6BAAsB,CAAC,4CAA4C,EACnE,aAAa,EACb;QACE,SAAS,EACP,6BAAsB,CAAC,4CAA4C;KACtE,CACF,CAAC;AACJ,CAAC;AAbD,wEAaC"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,wCAAwC;AACxC,+CAA+C;AAC/C,gEAAgE;;AAEhE,yCAAkE;AAElE,iCAA8C;AAiDjC,QAAA,iCAAiC,GAC5C,mCAAmC,CAAC;AAEzB,QAAA,sBAAsB,GAAG,wBAAwB,CAAC;AAE/D;;GAEG;AACH,SAAgB,8BAA8B,CAC5C,OAAgB,EAChB,aAAkD;IAElD,mBAAY,CACV,OAAO,EACP,6BAAsB,CAAC,4CAA4C,EACnE,aAAa,EACb;QACE,SAAS,EACP,6BAAsB,CAAC,4CAA4C;KACtE,CACF,CAAC;AACJ,CAAC;AAbD,wEAaC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loopback/authentication",
3
- "version": "2.2.0",
3
+ "version": "2.2.2",
4
4
  "description": "A LoopBack component for authentication support.",
5
5
  "engines": {
6
6
  "node": ">=8.9"
@@ -19,20 +19,19 @@
19
19
  "copyright.owner": "IBM Corp.",
20
20
  "license": "MIT",
21
21
  "dependencies": {
22
- "@loopback/context": "^1.22.0",
23
- "@loopback/core": "^1.10.0",
24
- "@loopback/metadata": "^1.3.0",
25
- "@loopback/openapi-v3": "^1.9.5",
26
- "@loopback/rest": "^1.18.0",
27
- "@loopback/security": "^0.1.0",
22
+ "@loopback/context": "^1.21.4",
23
+ "@loopback/core": "^1.9.3",
24
+ "@loopback/metadata": "^1.2.10",
25
+ "@loopback/openapi-v3": "^1.9.4",
26
+ "@loopback/rest": "^1.17.0",
28
27
  "@types/express": "^4.17.1"
29
28
  },
30
29
  "devDependencies": {
31
- "@loopback/build": "^2.0.9",
32
- "@loopback/eslint-config": "^4.0.2",
33
- "@loopback/openapi-spec-builder": "^1.2.11",
34
- "@loopback/testlab": "^1.7.5",
35
- "@types/node": "^10.14.17",
30
+ "@loopback/build": "^2.0.8",
31
+ "@loopback/eslint-config": "^4.0.1",
32
+ "@loopback/openapi-spec-builder": "^1.2.10",
33
+ "@loopback/testlab": "^1.7.4",
34
+ "@types/node": "^10.14.15",
36
35
  "jsonwebtoken": "^8.5.1"
37
36
  },
38
37
  "keywords": [
@@ -51,6 +50,5 @@
51
50
  "type": "git",
52
51
  "url": "https://github.com/strongloop/loopback-next.git",
53
52
  "directory": "packages/authentication"
54
- },
55
- "gitHead": "2cc8fa9318b1592845fa251fdd28d7f3225a70c0"
53
+ }
56
54
  }
@@ -4,8 +4,8 @@
4
4
  // License text available at https://opensource.org/licenses/MIT
5
5
 
6
6
  import {
7
- Constructor,
8
7
  MetadataInspector,
8
+ Constructor,
9
9
  MethodDecoratorFactory,
10
10
  } from '@loopback/context';
11
11
  import {AUTHENTICATION_METADATA_KEY} from '../keys';
@@ -31,7 +31,6 @@ export function authenticate(strategyName: string, options?: object) {
31
31
  strategy: strategyName,
32
32
  options: options || {},
33
33
  },
34
- {decoratorName: '@authenticate'},
35
34
  );
36
35
  }
37
36
 
package/src/index.ts CHANGED
@@ -6,6 +6,5 @@
6
6
  export * from './authentication.component';
7
7
  export * from './decorators';
8
8
  export * from './keys';
9
- export * from './providers';
10
9
  export * from './services';
11
10
  export * from './types';
package/src/keys.ts CHANGED
@@ -5,9 +5,8 @@
5
5
 
6
6
  import {BindingKey} from '@loopback/context';
7
7
  import {MetadataAccessor} from '@loopback/metadata';
8
- import {SecurityBindings} from '@loopback/security';
9
8
  import {AuthenticationMetadata} from './decorators';
10
- import {AuthenticateFn, AuthenticationStrategy} from './types';
9
+ import {AuthenticateFn, AuthenticationStrategy, UserProfile} from './types';
11
10
 
12
11
  /**
13
12
  * Binding keys used by this component.
@@ -87,11 +86,27 @@ export namespace AuthenticationBindings {
87
86
  'authentication.operationMetadata',
88
87
  );
89
88
 
89
+ /**
90
+ * Key used to inject the user instance retrieved by the
91
+ * authentication function
92
+ *
93
+ * @example
94
+ * ```ts
95
+ * class MyController {
96
+ * constructor(
97
+ * @inject(AuthenticationBindings.CURRENT_USER) private user: UserProfile,
98
+ * ) {}
99
+ *
100
+ * // ... routes that may need authentication
101
+ * ```
102
+ * }
103
+ */
104
+ export const CURRENT_USER = BindingKey.create<UserProfile | undefined>(
105
+ 'authentication.currentUser',
106
+ );
107
+
90
108
  export const AUTHENTICATION_STRATEGY_EXTENSION_POINT_NAME =
91
109
  'authentication.strategies';
92
-
93
- // Make `CURRENT_USER` the alias of the security bindings
94
- export const CURRENT_USER = SecurityBindings.USER;
95
110
  }
96
111
 
97
112
  /**
@@ -5,11 +5,11 @@
5
5
 
6
6
  import {Getter, inject, Provider, Setter} from '@loopback/context';
7
7
  import {Request} from '@loopback/rest';
8
- import {SecurityBindings, UserProfile} from '@loopback/security';
9
8
  import {AuthenticationBindings} from '../keys';
10
9
  import {
11
10
  AuthenticateFn,
12
11
  AuthenticationStrategy,
12
+ UserProfile,
13
13
  USER_PROFILE_NOT_FOUND,
14
14
  } from '../types';
15
15
  /**
@@ -27,7 +27,7 @@ export class AuthenticateActionProvider implements Provider<AuthenticateFn> {
27
27
  // is executed.
28
28
  @inject.getter(AuthenticationBindings.STRATEGY)
29
29
  readonly getStrategy: Getter<AuthenticationStrategy>,
30
- @inject.setter(SecurityBindings.USER)
30
+ @inject.setter(AuthenticationBindings.CURRENT_USER)
31
31
  readonly setCurrentUser: Setter<UserProfile>,
32
32
  ) {}
33
33
 
@@ -29,9 +29,9 @@ export class AuthenticationStrategyProvider
29
29
  implements Provider<AuthenticationStrategy | undefined> {
30
30
  constructor(
31
31
  @extensions()
32
- protected authenticationStrategies: Getter<AuthenticationStrategy[]>,
32
+ private authenticationStrategies: Getter<AuthenticationStrategy[]>,
33
33
  @inject(AuthenticationBindings.METADATA)
34
- protected metadata?: AuthenticationMetadata,
34
+ private metadata?: AuthenticationMetadata,
35
35
  ) {}
36
36
  async value(): Promise<AuthenticationStrategy | undefined> {
37
37
  if (!this.metadata) {
@@ -3,7 +3,7 @@
3
3
  // This file is licensed under the MIT License.
4
4
  // License text available at https://opensource.org/licenses/MIT
5
5
 
6
- import {UserProfile} from '@loopback/security';
6
+ import {UserProfile} from '../types';
7
7
 
8
8
  /**
9
9
  * An interface for generating and verifying a token
@@ -3,7 +3,7 @@
3
3
  // This file is licensed under the MIT License.
4
4
  // License text available at https://opensource.org/licenses/MIT
5
5
 
6
- import {UserProfile} from '@loopback/security';
6
+ import {UserProfile} from '../types';
7
7
 
8
8
  /**
9
9
  * A service for performing the login action in an authentication strategy.
package/src/types.ts CHANGED
@@ -5,7 +5,6 @@
5
5
 
6
6
  import {addExtension, Constructor, Context} from '@loopback/core';
7
7
  import {Request} from '@loopback/rest';
8
- import {UserProfile} from '@loopback/security';
9
8
  import {AuthenticationBindings} from './keys';
10
9
 
11
10
  /**
@@ -16,6 +15,16 @@ export interface AuthenticateFn {
16
15
  (request: Request): Promise<UserProfile | undefined>;
17
16
  }
18
17
 
18
+ /**
19
+ * interface definition of a user profile
20
+ * http://openid.net/specs/openid-connect-core-1_0.html#StandardClaims
21
+ */
22
+ export interface UserProfile {
23
+ id: string;
24
+ name?: string;
25
+ email?: string;
26
+ }
27
+
19
28
  /**
20
29
  * An interface that describes the common authentication strategy.
21
30
  *