@loopback/authentication 4.2.6 → 4.2.10

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,6 +3,45 @@
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
+ ## [4.2.10](https://github.com/strongloop/loopback-next/compare/@loopback/authentication@4.2.9...@loopback/authentication@4.2.10) (2020-07-20)
7
+
8
+ **Note:** Version bump only for package @loopback/authentication
9
+
10
+
11
+
12
+
13
+
14
+ ## [4.2.9](https://github.com/strongloop/loopback-next/compare/@loopback/authentication@4.2.8...@loopback/authentication@4.2.9) (2020-06-30)
15
+
16
+ **Note:** Version bump only for package @loopback/authentication
17
+
18
+
19
+
20
+
21
+
22
+ ## [4.2.8](https://github.com/strongloop/loopback-next/compare/@loopback/authentication@4.2.7...@loopback/authentication@4.2.8) (2020-06-23)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * set node version to >=10.16 to support events.once ([e39da1c](https://github.com/strongloop/loopback-next/commit/e39da1ca47728eafaf83c10ce35b09b03b6a4edc))
28
+ * **docs:** fix broken links ([0e63a6b](https://github.com/strongloop/loopback-next/commit/0e63a6b79b3dc727b01ff4031548b3d3aeceb544))
29
+
30
+
31
+
32
+
33
+
34
+ ## [4.2.7](https://github.com/strongloop/loopback-next/compare/@loopback/authentication@4.2.6...@loopback/authentication@4.2.7) (2020-06-11)
35
+
36
+
37
+ ### Bug Fixes
38
+
39
+ * remove unused dependency `@loopback/metadata` ([c0b87c3](https://github.com/strongloop/loopback-next/commit/c0b87c3d49d3e4cf57a01e95c5c55267cf7b054b))
40
+
41
+
42
+
43
+
44
+
6
45
  ## [4.2.6](https://github.com/strongloop/loopback-next/compare/@loopback/authentication@4.2.5...@loopback/authentication@4.2.6) (2020-05-28)
7
46
 
8
47
  **Note:** Version bump only for package @loopback/authentication
package/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # @loopback/authentication
2
2
 
3
- A LoopBack 4 component for authentication support.
3
+ A LoopBack 4 component for authentication support. Its corresponding
4
+ documentation is in
5
+ [LoopBack component authentication](https://loopback.io/doc/en/lb4/Loopback-component-authentication.html)
4
6
 
5
7
  ## Overview
6
8
 
@@ -25,22 +27,22 @@ npm install --save @loopback/authentication
25
27
 
26
28
  ## Basic Use
27
29
 
28
- [Load the AuthenticationComponent](https://loopback.io/doc/en/lb4/Loopback-component-authentication.html#authentication-component)
30
+ [Load the AuthenticationComponent](https://loopback.io/doc/en/lb4/Loopback-component-authentication.html#mounting-authentication-component)
29
31
  into your application.
30
32
 
31
33
  **Extension developers** need to:
32
34
 
33
- - [create custom authentication strategies](https://loopback.io/doc/en/lb4/Loopback-component-authentication.html#creating-a-custom-authentication-strategy)
35
+ - [create custom authentication strategies](https://loopback.io/doc/en/lb4/Implement-your-own-strategy.html)
34
36
 
35
37
  **Application Developers** need to:
36
38
 
37
- - [decorate controller functions with the authentication decorator](https://loopback.io/doc/en/lb4/Loopback-component-authentication.html#using-the-authentication-decorator)
38
- - [add the authentication action to a custom sequence](https://loopback.io/doc/en/lb4/Loopback-component-authentication.html#adding-an-authentication-action-to-a-custom-sequence)
39
+ - [decorate controller functions with the authentication decorator](https://loopback.io/doc/en/lb4/Authentication-component-decorator.html)
40
+ - [add the authentication action to a custom sequence](https://loopback.io/doc/en/lb4/Authentication-component-action.html#adding-an-authentication-action-to-a-custom-sequence)
39
41
  and
40
- [bind the custom sequence to the application](https://loopback.io/doc/en/lb4/Loopback-component-authentication.html#binding-the-authenticating-sequence-to-the-application)
41
- - [register the authentication strategies](https://loopback.io/doc/en/lb4/Loopback-component-authentication.html#registering-a-custom-authentication-strategy)
42
+ [bind the custom sequence to the application](https://loopback.io/doc/en/lb4/Authentication-component-action.html#binding-the-authenticating-sequence-to-the-application)
43
+ - [register the authentication strategies](https://loopback.io/doc/en/lb4/Authentication-component-strategy.html)
42
44
 
43
- [Create and register a passport based strategy](https://www.npmjs.com/package/@loopback/authentication-passport)
45
+ [Create and register a passport based strategy](https://loopback.io/doc/en/lb4/Authentication-passport.html)
44
46
 
45
47
  ## Related resources
46
48
 
@@ -48,7 +50,7 @@ For detailed documentation, see
48
50
  [AuthenticationComponent](https://loopback.io/doc/en/lb4/Loopback-component-authentication.html).
49
51
 
50
52
  For a tutorial on how to add **JWT** authentication to an application, see
51
- [How to secure your LoopBack 4 application with JWT authentication](https://loopback.io/doc/en/lb4/Authentication-Tutorial.html).
53
+ [How to secure your LoopBack 4 application with JWT authentication](https://loopback.io/doc/en/lb4/Authentication-tutorial.html).
52
54
 
53
55
  For some background on our design decisions, please read
54
56
  [Multiple Authentication strategies](./docs/authentication-system.md).
@@ -9,21 +9,18 @@ const tslib_1 = require("tslib");
9
9
  const core_1 = require("@loopback/core");
10
10
  const keys_1 = require("./keys");
11
11
  const providers_1 = require("./providers");
12
- let AuthenticationComponent = /** @class */ (() => {
13
- let AuthenticationComponent = class AuthenticationComponent {
14
- constructor() {
15
- this.providers = {
16
- [keys_1.AuthenticationBindings.AUTH_ACTION.key]: providers_1.AuthenticateActionProvider,
17
- [keys_1.AuthenticationBindings.STRATEGY.key]: providers_1.AuthenticationStrategyProvider,
18
- [keys_1.AuthenticationBindings.METADATA.key]: providers_1.AuthMetadataProvider,
19
- };
20
- }
21
- };
22
- AuthenticationComponent = tslib_1.__decorate([
23
- core_1.bind({ tags: { [core_1.ContextTags.KEY]: keys_1.AuthenticationBindings.COMPONENT } }),
24
- tslib_1.__metadata("design:paramtypes", [])
25
- ], AuthenticationComponent);
26
- return AuthenticationComponent;
27
- })();
12
+ let AuthenticationComponent = class AuthenticationComponent {
13
+ constructor() {
14
+ this.providers = {
15
+ [keys_1.AuthenticationBindings.AUTH_ACTION.key]: providers_1.AuthenticateActionProvider,
16
+ [keys_1.AuthenticationBindings.STRATEGY.key]: providers_1.AuthenticationStrategyProvider,
17
+ [keys_1.AuthenticationBindings.METADATA.key]: providers_1.AuthMetadataProvider,
18
+ };
19
+ }
20
+ };
21
+ AuthenticationComponent = tslib_1.__decorate([
22
+ core_1.bind({ tags: { [core_1.ContextTags.KEY]: keys_1.AuthenticationBindings.COMPONENT } }),
23
+ tslib_1.__metadata("design:paramtypes", [])
24
+ ], AuthenticationComponent);
28
25
  exports.AuthenticationComponent = AuthenticationComponent;
29
26
  //# sourceMappingURL=authentication.component.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"authentication.component.js","sourceRoot":"","sources":["../src/authentication.component.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,wCAAwC;AACxC,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,yCAAyE;AACzE,iCAA8C;AAC9C,2CAIqB;AAGrB;IAAA,IAAa,uBAAuB,GAApC,MAAa,uBAAuB;QAGlC;YACE,IAAI,CAAC,SAAS,GAAG;gBACf,CAAC,6BAAsB,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,sCAA0B;gBACpE,CAAC,6BAAsB,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,0CAA8B;gBACrE,CAAC,6BAAsB,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,gCAAoB;aAC5D,CAAC;QACJ,CAAC;KACF,CAAA;IAVY,uBAAuB;QADnC,WAAI,CAAC,EAAC,IAAI,EAAE,EAAC,CAAC,kBAAW,CAAC,GAAG,CAAC,EAAE,6BAAsB,CAAC,SAAS,EAAC,EAAC,CAAC;;OACvD,uBAAuB,CAUnC;IAAD,8BAAC;KAAA;AAVY,0DAAuB"}
1
+ {"version":3,"file":"authentication.component.js","sourceRoot":"","sources":["../src/authentication.component.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,wCAAwC;AACxC,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,yCAAyE;AACzE,iCAA8C;AAC9C,2CAIqB;AAGrB,IAAa,uBAAuB,GAApC,MAAa,uBAAuB;IAGlC;QACE,IAAI,CAAC,SAAS,GAAG;YACf,CAAC,6BAAsB,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,sCAA0B;YACpE,CAAC,6BAAsB,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,0CAA8B;YACrE,CAAC,6BAAsB,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,gCAAoB;SAC5D,CAAC;IACJ,CAAC;CACF,CAAA;AAVY,uBAAuB;IADnC,WAAI,CAAC,EAAC,IAAI,EAAE,EAAC,CAAC,kBAAW,CAAC,GAAG,CAAC,EAAE,6BAAsB,CAAC,SAAS,EAAC,EAAC,CAAC;;GACvD,uBAAuB,CAUnC;AAVY,0DAAuB"}
@@ -1,4 +1,4 @@
1
- import { Constructor } from '@loopback/context';
1
+ import { Constructor } from '@loopback/core';
2
2
  import { AuthenticationMetadata } from '../types';
3
3
  /**
4
4
  * Mark a controller method as requiring authenticated user.
@@ -5,9 +5,9 @@
5
5
  // License text available at https://opensource.org/licenses/MIT
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.getAuthenticateMetadata = exports.authenticate = void 0;
8
- const context_1 = require("@loopback/context");
8
+ const core_1 = require("@loopback/core");
9
9
  const keys_1 = require("../keys");
10
- class AuthenticateClassDecoratorFactory extends context_1.ClassDecoratorFactory {
10
+ class AuthenticateClassDecoratorFactory extends core_1.ClassDecoratorFactory {
11
11
  }
12
12
  /**
13
13
  * Mark a controller method as requiring authenticated user.
@@ -34,7 +34,7 @@ function authenticate(strategyNameOrMetadata, options) {
34
34
  }
35
35
  if (method && methodDescriptor) {
36
36
  // Method
37
- return context_1.MethodDecoratorFactory.createDecorator(keys_1.AUTHENTICATION_METADATA_KEY, spec, { decoratorName: '@authenticate' })(target, method, methodDescriptor);
37
+ return core_1.MethodDecoratorFactory.createDecorator(keys_1.AUTHENTICATION_METADATA_KEY, spec, { decoratorName: '@authenticate' })(target, method, methodDescriptor);
38
38
  }
39
39
  if (typeof target === 'function' && !method && !methodDescriptor) {
40
40
  // Class
@@ -42,7 +42,7 @@ function authenticate(strategyNameOrMetadata, options) {
42
42
  }
43
43
  // Not on a class or method
44
44
  throw new Error('@intercept cannot be used on a property: ' +
45
- context_1.DecoratorFactory.getTargetName(target, method, methodDescriptor));
45
+ core_1.DecoratorFactory.getTargetName(target, method, methodDescriptor));
46
46
  };
47
47
  }
48
48
  exports.authenticate = authenticate;
@@ -60,11 +60,11 @@ exports.authenticate = authenticate;
60
60
  */
61
61
  function getAuthenticateMetadata(targetClass, methodName) {
62
62
  // First check method level
63
- let metadata = context_1.MetadataInspector.getMethodMetadata(keys_1.AUTHENTICATION_METADATA_METHOD_KEY, targetClass.prototype, methodName);
63
+ let metadata = core_1.MetadataInspector.getMethodMetadata(keys_1.AUTHENTICATION_METADATA_METHOD_KEY, targetClass.prototype, methodName);
64
64
  if (metadata)
65
65
  return metadata;
66
66
  // Check if the class level has `@authenticate`
67
- metadata = context_1.MetadataInspector.getClassMetadata(keys_1.AUTHENTICATION_METADATA_CLASS_KEY, targetClass);
67
+ metadata = core_1.MetadataInspector.getClassMetadata(keys_1.AUTHENTICATION_METADATA_CLASS_KEY, targetClass);
68
68
  return metadata;
69
69
  }
70
70
  exports.getAuthenticateMetadata = getAuthenticateMetadata;
@@ -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,+CAM2B;AAC3B,kCAIiB;AAGjB,MAAM,iCAAkC,SAAQ,+BAE/C;CAAG;AAEJ;;;;;;GAMG;AACH,SAAgB,YAAY,CAC1B,sBAAuD,EACvD,OAAgB;IAEhB,OAAO,SAAS,qCAAqC;IACnD,uBAAuB;IACvB,8DAA8D;IAC9D,MAAW,EACX,MAAe;IACf,6CAA6C;IAC7C,4DAA4D;IAC5D,8DAA8D;IAC9D,gBAA+C;QAE/C,IAAI,IAA4B,CAAC;QACjC,IAAI,OAAO,sBAAsB,KAAK,QAA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,CAAC,CAAC;SACX;QACD,2BAA2B;QAC3B,MAAM,IAAI,KAAK,CACb,2CAA2C;YACzC,uBAAgB,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,CAAC,CACnE,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AA1CD,oCA0CC;AAED,WAAiB,YAAY;IAC3B;;OAEG;IACU,iBAAI,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,EAAC,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAC,CAAC,CAAC;AACrE,CAAC,EALgB,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAK5B;AAED;;;;;GAKG;AACH,SAAgB,uBAAuB,CACrC,WAA4B,EAC5B,UAAkB;IAElB,2BAA2B;IAC3B,IAAI,QAAQ,GAAG,wBAAiB,CAAC,iBAAiB,CAChD,yCAAkC,EAClC,WAAW,CAAC,SAAS,EACrB,UAAU,CACX,CAAC;IACF,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAC9B,+CAA+C;IAC/C,QAAQ,GAAG,wBAAiB,CAAC,gBAAgB,CAC3C,wCAAiC,EACjC,WAAW,CACZ,CAAC;IACF,OAAO,QAAQ,CAAC;AAClB,CAAC;AAjBD,0DAiBC"}
package/dist/keys.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import { BindingKey } from '@loopback/context';
2
- import { MetadataAccessor } from '@loopback/metadata';
1
+ import { BindingKey, MetadataAccessor } from '@loopback/core';
3
2
  import { UserProfile } from '@loopback/security';
4
3
  import { AuthenticationComponent } from './authentication.component';
5
4
  import { AuthenticateFn, AuthenticationMetadata, AuthenticationStrategy, UserProfileFactory } from './types';
package/dist/keys.js CHANGED
@@ -5,15 +5,14 @@
5
5
  // License text available at https://opensource.org/licenses/MIT
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.AUTHENTICATION_METADATA_CLASS_KEY = exports.AUTHENTICATION_METADATA_KEY = exports.AUTHENTICATION_METADATA_METHOD_KEY = exports.AuthenticationBindings = void 0;
8
- const context_1 = require("@loopback/context");
9
- const metadata_1 = require("@loopback/metadata");
8
+ const core_1 = require("@loopback/core");
10
9
  const security_1 = require("@loopback/security");
11
10
  /**
12
11
  * Binding keys used by this component.
13
12
  */
14
13
  var AuthenticationBindings;
15
14
  (function (AuthenticationBindings) {
16
- AuthenticationBindings.COMPONENT = context_1.BindingKey.create('components.AuthenticationComponent');
15
+ AuthenticationBindings.COMPONENT = core_1.BindingKey.create('components.AuthenticationComponent');
17
16
  /**
18
17
  * Key used to bind a user profile factory to the context for any
19
18
  * consumer to use when they need to convert a user object
@@ -27,7 +26,7 @@ var AuthenticationBindings;
27
26
  * ```
28
27
  */
29
28
  /* eslint-disable @typescript-eslint/no-explicit-any */
30
- AuthenticationBindings.USER_PROFILE_FACTORY = context_1.BindingKey.create('authentication.userProfileFactory');
29
+ AuthenticationBindings.USER_PROFILE_FACTORY = core_1.BindingKey.create('authentication.userProfileFactory');
31
30
  /**
32
31
  * Key used to bind an authentication strategy to the context for the
33
32
  * authentication function to use.
@@ -39,7 +38,7 @@ var AuthenticationBindings;
39
38
  * .toProvider(MyAuthenticationStrategy);
40
39
  * ```
41
40
  */
42
- AuthenticationBindings.STRATEGY = context_1.BindingKey.create('authentication.strategy');
41
+ AuthenticationBindings.STRATEGY = core_1.BindingKey.create('authentication.strategy');
43
42
  /**
44
43
  * Key used to inject the authentication function into the sequence.
45
44
  *
@@ -71,7 +70,7 @@ var AuthenticationBindings;
71
70
  * }
72
71
  * ```
73
72
  */
74
- AuthenticationBindings.AUTH_ACTION = context_1.BindingKey.create('authentication.actions.authenticate');
73
+ AuthenticationBindings.AUTH_ACTION = core_1.BindingKey.create('authentication.actions.authenticate');
75
74
  /**
76
75
  * Key used to inject authentication metadata, which is used to determine
77
76
  * whether a request requires authentication or not.
@@ -92,19 +91,19 @@ var AuthenticationBindings;
92
91
  * }
93
92
  * ```
94
93
  */
95
- AuthenticationBindings.METADATA = context_1.BindingKey.create('authentication.operationMetadata');
94
+ AuthenticationBindings.METADATA = core_1.BindingKey.create('authentication.operationMetadata');
96
95
  AuthenticationBindings.AUTHENTICATION_STRATEGY_EXTENSION_POINT_NAME = 'authentication.strategies';
97
96
  // Make `CURRENT_USER` the alias of SecurityBindings.USER for backward compatibility
98
97
  AuthenticationBindings.CURRENT_USER = security_1.SecurityBindings.USER;
99
98
  // Redirect url for authenticating current user
100
- AuthenticationBindings.AUTHENTICATION_REDIRECT_URL = context_1.BindingKey.create('authentication.redirect.url');
99
+ AuthenticationBindings.AUTHENTICATION_REDIRECT_URL = core_1.BindingKey.create('authentication.redirect.url');
101
100
  // Authentication redirect status, usually 302 or 303, indicates a web client will redirect
102
- AuthenticationBindings.AUTHENTICATION_REDIRECT_STATUS = context_1.BindingKey.create('authentication.redirect.status');
101
+ AuthenticationBindings.AUTHENTICATION_REDIRECT_STATUS = core_1.BindingKey.create('authentication.redirect.status');
103
102
  })(AuthenticationBindings = exports.AuthenticationBindings || (exports.AuthenticationBindings = {}));
104
103
  /**
105
104
  * The key used to store method-level metadata for `@authenticate`
106
105
  */
107
- exports.AUTHENTICATION_METADATA_METHOD_KEY = metadata_1.MetadataAccessor.create('authentication:method');
106
+ exports.AUTHENTICATION_METADATA_METHOD_KEY = core_1.MetadataAccessor.create('authentication:method');
108
107
  /**
109
108
  * Alias for AUTHENTICATION_METADATA_METHOD_KEY to keep it backward compatible
110
109
  */
@@ -112,5 +111,5 @@ exports.AUTHENTICATION_METADATA_KEY = exports.AUTHENTICATION_METADATA_METHOD_KEY
112
111
  /**
113
112
  * The key used to store class-level metadata for `@authenticate`
114
113
  */
115
- exports.AUTHENTICATION_METADATA_CLASS_KEY = metadata_1.MetadataAccessor.create('authentication:class');
114
+ exports.AUTHENTICATION_METADATA_CLASS_KEY = core_1.MetadataAccessor.create('authentication:class');
116
115
  //# sourceMappingURL=keys.js.map
package/dist/keys.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"keys.js","s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,CAAC,MAAM,CAGtE,sBAAsB,CAAC,CAAC"}
@@ -1,4 +1,4 @@
1
- import { Getter, Provider, Setter } from '@loopback/context';
1
+ import { Getter, Provider, Setter } from '@loopback/core';
2
2
  import { Request } from '@loopback/rest';
3
3
  import { UserProfile } from '@loopback/security';
4
4
  import { AuthenticateFn, AuthenticationStrategy } from '../types';
@@ -6,7 +6,7 @@
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.AuthenticateActionProvider = void 0;
8
8
  const tslib_1 = require("tslib");
9
- const context_1 = require("@loopback/context");
9
+ const core_1 = require("@loopback/core");
10
10
  const rest_1 = require("@loopback/rest");
11
11
  const security_1 = require("@loopback/security");
12
12
  const keys_1 = require("../keys");
@@ -15,72 +15,69 @@ const types_1 = require("../types");
15
15
  * Provides the authentication action for a sequence
16
16
  * @example `context.bind('authentication.actions.authenticate').toProvider(AuthenticateActionProvider)`
17
17
  */
18
- let AuthenticateActionProvider = /** @class */ (() => {
19
- let AuthenticateActionProvider = class AuthenticateActionProvider {
20
- constructor(
21
- // The provider is instantiated for Sequence constructor,
22
- // at which time we don't have information about the current
23
- // route yet. This information is needed to determine
24
- // what auth strategy should be used.
25
- // To solve this, we are injecting a getter function that will
26
- // defer resolution of the strategy until authenticate() action
27
- // is executed.
28
- getStrategy, setCurrentUser, setRedirectUrl, setRedirectStatus) {
29
- this.getStrategy = getStrategy;
30
- this.setCurrentUser = setCurrentUser;
31
- this.setRedirectUrl = setRedirectUrl;
32
- this.setRedirectStatus = setRedirectStatus;
18
+ let AuthenticateActionProvider = class AuthenticateActionProvider {
19
+ constructor(
20
+ // The provider is instantiated for Sequence constructor,
21
+ // at which time we don't have information about the current
22
+ // route yet. This information is needed to determine
23
+ // what auth strategy should be used.
24
+ // To solve this, we are injecting a getter function that will
25
+ // defer resolution of the strategy until authenticate() action
26
+ // is executed.
27
+ getStrategy, setCurrentUser, setRedirectUrl, setRedirectStatus) {
28
+ this.getStrategy = getStrategy;
29
+ this.setCurrentUser = setCurrentUser;
30
+ this.setRedirectUrl = setRedirectUrl;
31
+ this.setRedirectStatus = setRedirectStatus;
32
+ }
33
+ /**
34
+ * @returns authenticateFn
35
+ */
36
+ value() {
37
+ return request => this.action(request);
38
+ }
39
+ /**
40
+ * The implementation of authenticate() sequence action.
41
+ * @param request - The incoming request provided by the REST layer
42
+ */
43
+ async action(request) {
44
+ const strategy = await this.getStrategy();
45
+ if (!strategy) {
46
+ // The invoked operation does not require authentication.
47
+ return undefined;
33
48
  }
34
- /**
35
- * @returns authenticateFn
36
- */
37
- value() {
38
- return request => this.action(request);
49
+ const authResponse = await strategy.authenticate(request);
50
+ let userProfile;
51
+ // response from `strategy.authenticate()` could return an object of type UserProfile or RedirectRoute
52
+ if (rest_1.RedirectRoute.isRedirectRoute(authResponse)) {
53
+ const redirectOptions = authResponse;
54
+ // bind redirection url and status to the context
55
+ // controller should handle actual redirection
56
+ this.setRedirectUrl(redirectOptions.targetLocation);
57
+ this.setRedirectStatus(redirectOptions.statusCode);
39
58
  }
40
- /**
41
- * The implementation of authenticate() sequence action.
42
- * @param request - The incoming request provided by the REST layer
43
- */
44
- async action(request) {
45
- const strategy = await this.getStrategy();
46
- if (!strategy) {
47
- // The invoked operation does not require authentication.
48
- return undefined;
49
- }
50
- const authResponse = await strategy.authenticate(request);
51
- let userProfile;
52
- // response from `strategy.authenticate()` could return an object of type UserProfile or RedirectRoute
53
- if (rest_1.RedirectRoute.isRedirectRoute(authResponse)) {
54
- const redirectOptions = authResponse;
55
- // bind redirection url and status to the context
56
- // controller should handle actual redirection
57
- this.setRedirectUrl(redirectOptions.targetLocation);
58
- this.setRedirectStatus(redirectOptions.statusCode);
59
- }
60
- else if (authResponse) {
61
- // if `strategy.authenticate()` returns an object of type UserProfile, set it as current user
62
- userProfile = authResponse;
63
- this.setCurrentUser(userProfile);
64
- return userProfile;
65
- }
66
- else if (!authResponse) {
67
- // important to throw a non-protocol-specific error here
68
- const error = new Error(`User profile not returned from strategy's authenticate function`);
69
- Object.assign(error, {
70
- code: types_1.USER_PROFILE_NOT_FOUND,
71
- });
72
- throw error;
73
- }
59
+ else if (authResponse) {
60
+ // if `strategy.authenticate()` returns an object of type UserProfile, set it as current user
61
+ userProfile = authResponse;
62
+ this.setCurrentUser(userProfile);
63
+ return userProfile;
74
64
  }
75
- };
76
- AuthenticateActionProvider = tslib_1.__decorate([
77
- tslib_1.__param(0, context_1.inject.getter(keys_1.AuthenticationBindings.STRATEGY)),
78
- tslib_1.__param(1, context_1.inject.setter(security_1.SecurityBindings.USER)),
79
- tslib_1.__param(2, context_1.inject.setter(keys_1.AuthenticationBindings.AUTHENTICATION_REDIRECT_URL)),
80
- tslib_1.__param(3, context_1.inject.setter(keys_1.AuthenticationBindings.AUTHENTICATION_REDIRECT_STATUS)),
81
- tslib_1.__metadata("design:paramtypes", [Function, Function, Function, Function])
82
- ], AuthenticateActionProvider);
83
- return AuthenticateActionProvider;
84
- })();
65
+ else if (!authResponse) {
66
+ // important to throw a non-protocol-specific error here
67
+ const error = new Error(`User profile not returned from strategy's authenticate function`);
68
+ Object.assign(error, {
69
+ code: types_1.USER_PROFILE_NOT_FOUND,
70
+ });
71
+ throw error;
72
+ }
73
+ }
74
+ };
75
+ AuthenticateActionProvider = tslib_1.__decorate([
76
+ tslib_1.__param(0, core_1.inject.getter(keys_1.AuthenticationBindings.STRATEGY)),
77
+ tslib_1.__param(1, core_1.inject.setter(security_1.SecurityBindings.USER)),
78
+ tslib_1.__param(2, core_1.inject.setter(keys_1.AuthenticationBindings.AUTHENTICATION_REDIRECT_URL)),
79
+ tslib_1.__param(3, core_1.inject.setter(keys_1.AuthenticationBindings.AUTHENTICATION_REDIRECT_STATUS)),
80
+ tslib_1.__metadata("design:paramtypes", [Function, Function, Function, Function])
81
+ ], AuthenticateActionProvider);
85
82
  exports.AuthenticateActionProvider = AuthenticateActionProvider;
86
83
  //# sourceMappingURL=auth-action.provider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth-action.provider.js","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AC;aACpD;iBAAM,IAAI,YAAY,EAAE;gBACvB,6FAA6F;gBAC7F,WAAW,GAAG,YAA2B,CAAC;gBAC1C,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;gBACjC,OAAO,WAAW,CAAC;aACpB;iBAAM,IAAI,CAAC,YAAY,EAAE;gBACxB,wDAAwD;gBACxD,MAAM,KAAK,GAAG,IAAI,KAAK,CACrB,iEAAiE,CAClE,CAAC;gBACF,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE;oBACnB,IAAI,EAAE,8BAAsB;iBAC7B,CAAC,CAAC;gBACH,MAAM,KAAK,CAAC;aACb;QACH,CAAC;KACF,CAAA;IA/DY,0BAA0B;QASlC,mBAAA,gBAAM,CAAC,MAAM,CAAC,6BAAsB,CAAC,QAAQ,CAAC,CAAA;QAE9C,mBAAA,gBAAM,CAAC,MAAM,CAAC,2BAAgB,CAAC,IAAI,CAAC,CAAA;QAEpC,mBAAA,gBAAM,CAAC,MAAM,CAAC,6BAAsB,CAAC,2BAA2B,CAAC,CAAA;QAEjE,mBAAA,gBAAM,CAAC,MAAM,CAAC,6BAAsB,CAAC,8BAA8B,CAAC,CAAA;;OAf5D,0BAA0B,CA+DtC;IAAD,iCAAC;KAAA;AA/DY,gEAA0B"}
1
+ {"version":3,"file":"auth-action.provider.js","sourceRoot":"","sources":["../../src/providers/auth-action.provider.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,wCAAwC;AACxC,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,yCAAgE;AAChE,yCAAsD;AACtD,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,EAEnC,cAA8B,EAE9B,iBAAiC;QANjC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AAA,aAAM,CAAC,MAAM,CAAC,6BAAsB,CAAC,QAAQ,CAAC,CAAA;IAE9C,mBAAA,aAAM,CAAC,MAAM,CAAC,2BAAgB,CAAC,IAAI,CAAC,CAAA;IAEpC,mBAAA,aAAM,CAAC,MAAM,CAAC,6BAAsB,CAAC,2BAA2B,CAAC,CAAA;IAEjE,mBAAA,aAAM,CAAC,MAAM,CAAC,6BAAsB,CAAC,8BAA8B,CAAC,CAAA;;GAf5D,0BAA0B,CA+DtC;AA/DY,gEAA0B"}
@@ -1,4 +1,4 @@
1
- import { Constructor, Provider } from '@loopback/context';
1
+ import { Constructor, Provider } from '@loopback/core';
2
2
  import { AuthenticationMetadata, AuthenticationOptions } from '../types';
3
3
  /**
4
4
  * Provides authentication metadata of a controller method
@@ -6,7 +6,6 @@
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.AuthMetadataProvider = void 0;
8
8
  const tslib_1 = require("tslib");
9
- const context_1 = require("@loopback/context");
10
9
  const core_1 = require("@loopback/core");
11
10
  const decorators_1 = require("../decorators");
12
11
  const keys_1 = require("../keys");
@@ -14,36 +13,33 @@ const keys_1 = require("../keys");
14
13
  * Provides authentication metadata of a controller method
15
14
  * @example `context.bind('authentication.operationMetadata').toProvider(AuthMetadataProvider)`
16
15
  */
17
- let AuthMetadataProvider = /** @class */ (() => {
18
- let AuthMetadataProvider = class AuthMetadataProvider {
19
- constructor(controllerClass, methodName, options = {}) {
20
- this.controllerClass = controllerClass;
21
- this.methodName = methodName;
22
- this.options = options;
23
- }
24
- /**
25
- * @returns AuthenticationMetadata
26
- */
27
- value() {
28
- if (!this.controllerClass || !this.methodName)
29
- return;
30
- const metadata = decorators_1.getAuthenticateMetadata(this.controllerClass, this.methodName);
31
- // Skip authentication if `skip` is `true`
32
- if (metadata === null || metadata === void 0 ? void 0 : metadata.skip)
33
- return undefined;
34
- if (metadata)
35
- return metadata;
36
- // Fall back to default metadata
37
- return this.options.defaultMetadata;
38
- }
39
- };
40
- AuthMetadataProvider = tslib_1.__decorate([
41
- tslib_1.__param(0, context_1.inject(core_1.CoreBindings.CONTROLLER_CLASS, { optional: true })),
42
- tslib_1.__param(1, context_1.inject(core_1.CoreBindings.CONTROLLER_METHOD_NAME, { optional: true })),
43
- tslib_1.__param(2, context_1.config({ fromBinding: keys_1.AuthenticationBindings.COMPONENT })),
44
- tslib_1.__metadata("design:paramtypes", [Object, String, Object])
45
- ], AuthMetadataProvider);
46
- return AuthMetadataProvider;
47
- })();
16
+ let AuthMetadataProvider = class AuthMetadataProvider {
17
+ constructor(controllerClass, methodName, options = {}) {
18
+ this.controllerClass = controllerClass;
19
+ this.methodName = methodName;
20
+ this.options = options;
21
+ }
22
+ /**
23
+ * @returns AuthenticationMetadata
24
+ */
25
+ value() {
26
+ if (!this.controllerClass || !this.methodName)
27
+ return;
28
+ const metadata = decorators_1.getAuthenticateMetadata(this.controllerClass, this.methodName);
29
+ // Skip authentication if `skip` is `true`
30
+ if (metadata === null || metadata === void 0 ? void 0 : metadata.skip)
31
+ return undefined;
32
+ if (metadata)
33
+ return metadata;
34
+ // Fall back to default metadata
35
+ return this.options.defaultMetadata;
36
+ }
37
+ };
38
+ AuthMetadataProvider = tslib_1.__decorate([
39
+ tslib_1.__param(0, core_1.inject(core_1.CoreBindings.CONTROLLER_CLASS, { optional: true })),
40
+ tslib_1.__param(1, core_1.inject(core_1.CoreBindings.CONTROLLER_METHOD_NAME, { optional: true })),
41
+ tslib_1.__param(2, core_1.config({ fromBinding: keys_1.AuthenticationBindings.COMPONENT })),
42
+ tslib_1.__metadata("design:paramtypes", [Object, String, Object])
43
+ ], AuthMetadataProvider);
48
44
  exports.AuthMetadataProvider = AuthMetadataProvider;
49
45
  //# sourceMappingURL=auth-metadata.provider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth-metadata.provider.js","sourceRoot":"","sources":["../../src/providers/auth-metadata.provider.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,wCAAwC;AACxC,+CAA+C;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EAAgE;;;;AAEhE,yCAMwB;AACxB,8CAAsD;AACtD,kCAA+C;AAG/C;;;GAGG;AACH,IAAa,oBAAoB,GAAjC,MAAa,oBAAoB;IAE/B,YAEmB,eAAgC,EAEhC,UAAkB,EAElB,UAAiC,EAAE;QAJnC,oBAAe,GAAf,eAAe,CAAiB;QAEhC,eAAU,GAAV,UAAU,CAAQ;QAElB,YAAO,GAAP,OAAO,CAA4B;IACnD,CAAC;IAEJ;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,IAAI,CAAC,eAAe,IAAI,CAAC,IAAI,CAAC,UAAU;YAAE,OAAO;QACtD,MAAM,QAAQ,GAAG,oCAAuB,CACtC,IAAI,CAAC,eAAe,EACpB,IAAI,CAAC,UAAU,CAChB,CAAC;QACF,0CAA0C;QAC1C,IAAI,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI;YAAE,OAAO,SAAS,CAAC;QACrC,IAAI,QAAQ;YAAE,OAAO,QAAQ,CAAC;QAC9B,gCAAgC;QAChC,OAAO,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC;IACtC,CAAC;CACF,CAAA;AA1BY,oBAAoB;IAG5B,mBAAA,aAAM,CAAC,mBAAY,CAAC,gBAAgB,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAA;IAEvD,mBAAA,aAAM,CAAC,mBAAY,CAAC,sBAAsB,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAA;IAE7D,mBAAA,aAAM,CAAC,EAAC,WAAW,EAAE,6BAAsB,CAAC,SAAS,EAAC,CAAC,CAAA;;GAP/C,oBAAoB,CA0BhC;AA1BY,oDAAoB"}
@@ -1,5 +1,4 @@
1
- import { Getter } from '@loopback/context';
2
- import { Provider } from '@loopback/core';
1
+ import { Getter, Provider } from '@loopback/core';
3
2
  import { AuthenticationMetadata, AuthenticationStrategy } from '../types';
4
3
  /**
5
4
  * An authentication strategy provider responsible for
@@ -6,7 +6,6 @@
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.AuthenticationStrategyProvider = void 0;
8
8
  const tslib_1 = require("tslib");
9
- const context_1 = require("@loopback/context");
10
9
  const core_1 = require("@loopback/core");
11
10
  const keys_1 = require("../keys");
12
11
  const types_1 = require("../types");
@@ -19,42 +18,39 @@ const types_1 = require("../types");
19
18
  *
20
19
  * @example `context.bind('authentication.strategy').toProvider(AuthenticationStrategyProvider)`
21
20
  */
22
- let AuthenticationStrategyProvider = /** @class */ (() => {
23
- let AuthenticationStrategyProvider = class AuthenticationStrategyProvider {
24
- constructor(authenticationStrategies, metadata) {
25
- this.authenticationStrategies = authenticationStrategies;
26
- this.metadata = metadata;
21
+ let AuthenticationStrategyProvider = class AuthenticationStrategyProvider {
22
+ constructor(authenticationStrategies, metadata) {
23
+ this.authenticationStrategies = authenticationStrategies;
24
+ this.metadata = metadata;
25
+ }
26
+ async value() {
27
+ if (!this.metadata) {
28
+ return undefined;
27
29
  }
28
- async value() {
29
- if (!this.metadata) {
30
- return undefined;
31
- }
32
- const name = this.metadata.strategy;
33
- const strategy = await this.findAuthenticationStrategy(name);
34
- if (!strategy) {
35
- // important to throw a non-protocol-specific error here
36
- const error = new Error(`The strategy '${name}' is not available.`);
37
- Object.assign(error, {
38
- code: types_1.AUTHENTICATION_STRATEGY_NOT_FOUND,
39
- });
40
- throw error;
41
- }
42
- return strategy;
30
+ const name = this.metadata.strategy;
31
+ const strategy = await this.findAuthenticationStrategy(name);
32
+ if (!strategy) {
33
+ // important to throw a non-protocol-specific error here
34
+ const error = new Error(`The strategy '${name}' is not available.`);
35
+ Object.assign(error, {
36
+ code: types_1.AUTHENTICATION_STRATEGY_NOT_FOUND,
37
+ });
38
+ throw error;
43
39
  }
44
- async findAuthenticationStrategy(name) {
45
- const strategies = await this.authenticationStrategies();
46
- const matchingAuthStrategy = strategies.find(a => a.name === name);
47
- return matchingAuthStrategy;
48
- }
49
- };
50
- AuthenticationStrategyProvider = tslib_1.__decorate([
51
- core_1.extensionPoint(keys_1.AuthenticationBindings.AUTHENTICATION_STRATEGY_EXTENSION_POINT_NAME, { scope: context_1.BindingScope.TRANSIENT }) //this needs to be transient, e.g. for request level context.
52
- ,
53
- tslib_1.__param(0, core_1.extensions()),
54
- tslib_1.__param(1, context_1.inject(keys_1.AuthenticationBindings.METADATA)),
55
- tslib_1.__metadata("design:paramtypes", [Function, Object])
56
- ], AuthenticationStrategyProvider);
57
- return AuthenticationStrategyProvider;
58
- })();
40
+ return strategy;
41
+ }
42
+ async findAuthenticationStrategy(name) {
43
+ const strategies = await this.authenticationStrategies();
44
+ const matchingAuthStrategy = strategies.find(a => a.name === name);
45
+ return matchingAuthStrategy;
46
+ }
47
+ };
48
+ AuthenticationStrategyProvider = tslib_1.__decorate([
49
+ core_1.extensionPoint(keys_1.AuthenticationBindings.AUTHENTICATION_STRATEGY_EXTENSION_POINT_NAME, { scope: core_1.BindingScope.TRANSIENT }) //this needs to be transient, e.g. for request level context.
50
+ ,
51
+ tslib_1.__param(0, core_1.extensions()),
52
+ tslib_1.__param(1, core_1.inject(keys_1.AuthenticationBindings.METADATA)),
53
+ tslib_1.__metadata("design:paramtypes", [Function, Object])
54
+ ], AuthenticationStrategyProvider);
59
55
  exports.AuthenticationStrategyProvider = AuthenticationStrategyProvider;
60
56
  //# sourceMappingURL=auth-strategy.provider.js.map
@@ -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;AACpE,kCAA+C;AAC/C,oCAIkB;AAElB;;;;;;;;GAQG;AAKH;IAAA,IAAa,8BAA8B,GAA3C,MAAa,8BAA8B;QAEzC,YAEY,wBAA0D,EAE1D,QAAiC;YAFjC,6BAAwB,GAAxB,wBAAwB,CAAkC;YAE1D,aAAQ,GAAR,QAAQ,C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AAA;;GAL/B,8BAA8B,CA8B1C;AA9BY,wEAA8B"}
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@loopback/authentication",
3
- "version": "4.2.6",
3
+ "version": "4.2.10",
4
4
  "description": "A LoopBack component for authentication support.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "engines": {
8
- "node": ">=10"
8
+ "node": ">=10.16"
9
9
  },
10
10
  "scripts": {
11
11
  "acceptance": "lb-mocha \"dist/__tests__/acceptance/**/*.js\"",
@@ -20,24 +20,24 @@
20
20
  "author": "IBM Corp.",
21
21
  "copyright.owner": "IBM Corp.",
22
22
  "license": "MIT",
23
+ "publishConfig": {
24
+ "access": "public"
25
+ },
23
26
  "dependencies": {
24
- "@loopback/context": "^3.8.2",
25
- "@loopback/core": "^2.7.1",
26
- "@loopback/metadata": "^2.1.6",
27
- "@loopback/openapi-v3": "^3.4.2",
28
- "@loopback/rest": "^5.1.0",
29
- "@loopback/security": "^0.2.11",
30
- "@types/express": "^4.17.6",
31
- "@types/lodash": "^4.14.153",
32
- "lodash": "^4.17.15",
27
+ "@loopback/core": "^2.9.2",
28
+ "@loopback/rest": "^5.2.1",
29
+ "@loopback/security": "^0.2.15",
30
+ "@types/express": "^4.17.7",
31
+ "@types/lodash": "^4.14.157",
32
+ "lodash": "^4.17.19",
33
33
  "tslib": "^2.0.0"
34
34
  },
35
35
  "devDependencies": {
36
- "@loopback/build": "^5.4.2",
37
- "@loopback/eslint-config": "^8.0.0",
38
- "@loopback/openapi-spec-builder": "^2.1.6",
39
- "@loopback/testlab": "^3.1.6",
40
- "@types/node": "^10.17.24",
36
+ "@loopback/build": "^6.1.1",
37
+ "@loopback/eslint-config": "^8.0.4",
38
+ "@loopback/openapi-spec-builder": "^2.1.10",
39
+ "@loopback/testlab": "^3.2.1",
40
+ "@types/node": "^10.17.27",
41
41
  "jsonwebtoken": "^8.5.1"
42
42
  },
43
43
  "keywords": [
@@ -55,5 +55,5 @@
55
55
  "url": "https://github.com/strongloop/loopback-next.git",
56
56
  "directory": "packages/authentication"
57
57
  },
58
- "gitHead": "64afb3616e94b96703524aba8be722efefa7c2c5"
58
+ "gitHead": "5538896411bb56467ae52670a29d1aec1690be74"
59
59
  }
@@ -9,7 +9,7 @@ import {
9
9
  DecoratorFactory,
10
10
  MetadataInspector,
11
11
  MethodDecoratorFactory,
12
- } from '@loopback/context';
12
+ } from '@loopback/core';
13
13
  import {
14
14
  AUTHENTICATION_METADATA_CLASS_KEY,
15
15
  AUTHENTICATION_METADATA_KEY,
package/src/keys.ts CHANGED
@@ -3,8 +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 {BindingKey} from '@loopback/context';
7
- import {MetadataAccessor} from '@loopback/metadata';
6
+ import {BindingKey, MetadataAccessor} from '@loopback/core';
8
7
  import {SecurityBindings, UserProfile} from '@loopback/security';
9
8
  import {AuthenticationComponent} from './authentication.component';
10
9
  import {
@@ -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 {Getter, inject, Provider, Setter} from '@loopback/context';
6
+ import {Getter, inject, Provider, Setter} from '@loopback/core';
7
7
  import {Request, RedirectRoute} from '@loopback/rest';
8
8
  import {SecurityBindings, UserProfile} from '@loopback/security';
9
9
  import {AuthenticationBindings} from '../keys';
@@ -3,8 +3,13 @@
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 {config, Constructor, inject, Provider} from '@loopback/context';
7
- import {CoreBindings} from '@loopback/core';
6
+ import {
7
+ config,
8
+ Constructor,
9
+ inject,
10
+ Provider,
11
+ CoreBindings,
12
+ } from '@loopback/core';
8
13
  import {getAuthenticateMetadata} from '../decorators';
9
14
  import {AuthenticationBindings} from '../keys';
10
15
  import {AuthenticationMetadata, AuthenticationOptions} from '../types';
@@ -3,8 +3,14 @@
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 {BindingScope, Getter, inject} from '@loopback/context';
7
- import {extensionPoint, extensions, Provider} from '@loopback/core';
6
+ import {
7
+ BindingScope,
8
+ Getter,
9
+ inject,
10
+ extensionPoint,
11
+ extensions,
12
+ Provider,
13
+ } from '@loopback/core';
8
14
  import {AuthenticationBindings} from '../keys';
9
15
  import {
10
16
  AuthenticationMetadata,