@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 +39 -0
- package/README.md +11 -9
- package/dist/authentication.component.js +13 -16
- package/dist/authentication.component.js.map +1 -1
- package/dist/decorators/authenticate.decorator.d.ts +1 -1
- package/dist/decorators/authenticate.decorator.js +6 -6
- package/dist/decorators/authenticate.decorator.js.map +1 -1
- package/dist/keys.d.ts +1 -2
- package/dist/keys.js +10 -11
- package/dist/keys.js.map +1 -1
- package/dist/providers/auth-action.provider.d.ts +1 -1
- package/dist/providers/auth-action.provider.js +62 -65
- package/dist/providers/auth-action.provider.js.map +1 -1
- package/dist/providers/auth-metadata.provider.d.ts +1 -1
- package/dist/providers/auth-metadata.provider.js +28 -32
- package/dist/providers/auth-metadata.provider.js.map +1 -1
- package/dist/providers/auth-strategy.provider.d.ts +1 -2
- package/dist/providers/auth-strategy.provider.js +32 -36
- package/dist/providers/auth-strategy.provider.js.map +1 -1
- package/package.json +17 -17
- package/src/decorators/authenticate.decorator.ts +1 -1
- package/src/keys.ts +1 -2
- package/src/providers/auth-action.provider.ts +1 -1
- package/src/providers/auth-metadata.provider.ts +7 -2
- package/src/providers/auth-strategy.provider.ts +8 -2
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/
|
|
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/
|
|
38
|
-
- [add the authentication action to a custom sequence](https://loopback.io/doc/en/lb4/
|
|
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/
|
|
41
|
-
- [register the authentication strategies](https://loopback.io/doc/en/lb4/
|
|
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://
|
|
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-
|
|
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 =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
|
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"}
|
|
@@ -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
|
|
8
|
+
const core_1 = require("@loopback/core");
|
|
9
9
|
const keys_1 = require("../keys");
|
|
10
|
-
class AuthenticateClassDecoratorFactory extends
|
|
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
|
|
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
|
-
|
|
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 =
|
|
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 =
|
|
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
|
|
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,yCAMwB;AACxB,kCAIiB;AAGjB,MAAM,iCAAkC,SAAQ,4BAE/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,QAAQ,EAAE;YAC9C,IAAI,GAAG,sBAAsB,CAAC;SAC/B;aAAM;YACL,IAAI,GAAG,EAAC,QAAQ,EAAE,sBAAsB,EAAE,OAAO,EAAE,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,EAAC,CAAC;SACnE;QACD,IAAI,MAAM,IAAI,gBAAgB,EAAE;YAC9B,SAAS;YACT,OAAO,6BAAsB,CAAC,eAAe,CAC3C,kCAA2B,EAC3B,IAAI,EACJ,EAAC,aAAa,EAAE,eAAe,EAAC,CACjC,CAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC;SACrC;QACD,IAAI,OAAO,MAAM,KAAK,UAAU,IAAI,CAAC,MAAM,IAAI,CAAC,gBAAgB,EAAE;YAChE,QAAQ;YACR,OAAO,iCAAiC,CAAC,eAAe,CACtD,wCAAiC,EACjC,IAAI,EACJ,EAAC,aAAa,EAAE,eAAe,EAAC,CACjC,CAAC,MAAM,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/
|
|
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
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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","sourceRoot":"","sources":["../src/keys.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,wCAAwC;AACxC,+CAA+C;AAC/C,gEAAgE;;;AAEhE
|
|
1
|
+
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../src/keys.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,wCAAwC;AACxC,+CAA+C;AAC/C,gEAAgE;;;AAEhE,yCAA4D;AAC5D,iDAAiE;AASjE;;GAEG;AACH,IAAiB,sBAAsB,CA+GtC;AA/GD,WAAiB,sBAAsB;IACxB,gCAAS,GAAG,iBAAU,CAAC,MAAM,CACxC,oCAAoC,CACrC,CAAC;IAEF;;;;;;;;;;;OAWG;IACH,uDAAuD;IAC1C,2CAAoB,GAAG,iBAAU,CAAC,MAAM,CAEnD,mCAAmC,CAAC,CAAC;IAEvC;;;;;;;;;;OAUG;IACU,+BAAQ,GAAG,iBAAU,CAAC,MAAM,CACvC,yBAAyB,CAC1B,CAAC;IAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACU,kCAAW,GAAG,iBAAU,CAAC,MAAM,CAC1C,qCAAqC,CACtC,CAAC;IAEF;;;;;;;;;;;;;;;;;;;OAmBG;IACU,+BAAQ,GAAG,iBAAU,CAAC,MAAM,CACvC,kCAAkC,CACnC,CAAC;IAEW,mEAA4C,GACvD,2BAA2B,CAAC;IAE9B,oFAAoF;IACvE,mCAAY,GAA4B,2BAAgB,CAAC,IAAI,CAAC;IAE3E,+CAA+C;IAClC,kDAA2B,GAAG,iBAAU,CAAC,MAAM,CAC1D,6BAA6B,CAC9B,CAAC;IAEF,2FAA2F;IAC9E,qDAA8B,GAAG,iBAAU,CAAC,MAAM,CAC7D,gCAAgC,CACjC,CAAC;AACJ,CAAC,EA/GgB,sBAAsB,GAAtB,8BAAsB,KAAtB,8BAAsB,QA+GtC;AAED;;GAEG;AACU,QAAA,kCAAkC,GAAG,uBAAgB,CAAC,MAAM,CAGvE,uBAAuB,CAAC,CAAC;AAE3B;;GAEG;AACU,QAAA,2BAA2B,GAAG,0CAAkC,CAAC;AAE9E;;GAEG;AACU,QAAA,iCAAiC,GAAG,uBAAgB,CAAC,MAAM,CAGtE,sBAAsB,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Getter, Provider, Setter } from '@loopback/
|
|
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
|
|
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 =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
getStrategy
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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","sourceRoot":"","sources":["../../src/providers/auth-action.provider.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,wCAAwC;AACxC,+CAA+C;AAC/C,gEAAgE;;;;AAEhE
|
|
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,gBAAW,GAAX,WAAW,CAAgC;QAE3C,mBAAc,GAAd,cAAc,CAAqB;QAEnC,mBAAc,GAAd,cAAc,CAAgB;QAE9B,sBAAiB,GAAjB,iBAAiB,CAAgB;IACzC,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,YAAY,GAAG,MAAM,QAAQ,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAC1D,IAAI,WAAwB,CAAC;QAE7B,sGAAsG;QACtG,IAAI,oBAAa,CAAC,eAAe,CAAC,YAAY,CAAC,EAAE;YAC/C,MAAM,eAAe,GAAG,YAAY,CAAC;YACrC,iDAAiD;YACjD,8CAA8C;YAC9C,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;YACpD,IAAI,CAAC,iBAAiB,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;SACpD;aAAM,IAAI,YAAY,EAAE;YACvB,6FAA6F;YAC7F,WAAW,GAAG,YAA2B,CAAC;YAC1C,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;YACjC,OAAO,WAAW,CAAC;SACpB;aAAM,IAAI,CAAC,YAAY,EAAE;YACxB,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;IACH,CAAC;CACF,CAAA;AA/DY,0BAA0B;IASlC,mBAAA,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"}
|
|
@@ -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 =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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;AAC/C,gEAAgE;;;;AAEhE
|
|
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;AAC/C,gEAAgE;;;;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/
|
|
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 =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
|
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,yCAOwB;AACxB,kCAA+C;AAC/C,oCAIkB;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,mBAAY,CAAC,SAAS,EAAC,CAChC,CAAC,6DAA6D;;IAI1D,mBAAA,iBAAU,EAAE,CAAA;IAEZ,mBAAA,aAAM,CAAC,6BAAsB,CAAC,QAAQ,CAAC,CAAA;;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.
|
|
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/
|
|
25
|
-
"@loopback/
|
|
26
|
-
"@loopback/
|
|
27
|
-
"@
|
|
28
|
-
"@
|
|
29
|
-
"
|
|
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": "^
|
|
37
|
-
"@loopback/eslint-config": "^8.0.
|
|
38
|
-
"@loopback/openapi-spec-builder": "^2.1.
|
|
39
|
-
"@loopback/testlab": "^3.1
|
|
40
|
-
"@types/node": "^10.17.
|
|
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": "
|
|
58
|
+
"gitHead": "5538896411bb56467ae52670a29d1aec1690be74"
|
|
59
59
|
}
|
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/
|
|
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/
|
|
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 {
|
|
7
|
-
|
|
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 {
|
|
7
|
-
|
|
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,
|