@feathersjs/authentication-oauth 5.0.0-pre.3 → 5.0.0-pre.30
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 +138 -162
- package/LICENSE +1 -1
- package/README.md +2 -2
- package/lib/index.d.ts +1 -3
- package/lib/index.js +22 -56
- package/lib/index.js.map +1 -1
- package/lib/service.d.ts +36 -0
- package/lib/service.js +141 -0
- package/lib/service.js.map +1 -0
- package/lib/strategy.d.ts +4 -3
- package/lib/strategy.js +95 -119
- package/lib/strategy.js.map +1 -1
- package/lib/utils.d.ts +13 -4
- package/lib/utils.js +90 -5
- package/lib/utils.js.map +1 -1
- package/package.json +32 -24
- package/src/index.ts +35 -66
- package/src/service.ts +177 -0
- package/src/strategy.ts +98 -81
- package/src/utils.ts +118 -12
- package/lib/express.d.ts +0 -16
- package/lib/express.js +0 -114
- package/lib/express.js.map +0 -1
- package/src/express.ts +0 -127
package/lib/index.js
CHANGED
|
@@ -1,71 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
const merge_1 = __importDefault(require("lodash/merge"));
|
|
8
|
-
const each_1 = __importDefault(require("lodash/each"));
|
|
9
|
-
const omit_1 = __importDefault(require("lodash/omit"));
|
|
3
|
+
exports.oauth = exports.OAuthStrategy = void 0;
|
|
10
4
|
const commons_1 = require("@feathersjs/commons");
|
|
5
|
+
const schema_1 = require("@feathersjs/schema");
|
|
11
6
|
const strategy_1 = require("./strategy");
|
|
12
7
|
Object.defineProperty(exports, "OAuthStrategy", { enumerable: true, get: function () { return strategy_1.OAuthStrategy; } });
|
|
13
|
-
const
|
|
8
|
+
const service_1 = require("./service");
|
|
14
9
|
const utils_1 = require("./utils");
|
|
15
|
-
const debug = commons_1.createDebug('@feathersjs/authentication-oauth');
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
if (!
|
|
10
|
+
const debug = (0, commons_1.createDebug)('@feathersjs/authentication-oauth');
|
|
11
|
+
const oauth = (settings = {}) => (app) => {
|
|
12
|
+
const authService = app.defaultAuthentication ? app.defaultAuthentication(settings.authService) : null;
|
|
13
|
+
if (!authService) {
|
|
19
14
|
throw new Error('An authentication service must exist before registering @feathersjs/authentication-oauth');
|
|
20
15
|
}
|
|
21
|
-
|
|
22
|
-
if (!oauth) {
|
|
16
|
+
if (!authService.configuration.oauth) {
|
|
23
17
|
debug('No oauth configuration found in authentication configuration. Skipping oAuth setup.');
|
|
24
18
|
return;
|
|
25
19
|
}
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const port = app.get('port');
|
|
30
|
-
let host = app.get('host');
|
|
31
|
-
let protocol = 'https';
|
|
32
|
-
// Development environments commonly run on HTTP with an extended port
|
|
33
|
-
if (app.get('env') === 'development') {
|
|
34
|
-
protocol = 'http';
|
|
35
|
-
if (String(port) !== '80') {
|
|
36
|
-
host += `:${port}`;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
const grant = merge_1.default({
|
|
40
|
-
defaults: {
|
|
41
|
-
prefix,
|
|
42
|
-
origin: `${protocol}://${host}`,
|
|
43
|
-
transport: 'session',
|
|
44
|
-
response: ['tokens', 'raw', 'profile']
|
|
45
|
-
}
|
|
46
|
-
}, omit_1.default(oauth, 'redirect'));
|
|
47
|
-
const getUrl = (url) => {
|
|
48
|
-
const { defaults } = grant;
|
|
49
|
-
return `${defaults.origin}${prefix}/${url}`;
|
|
20
|
+
const oauthOptions = {
|
|
21
|
+
linkStrategy: 'jwt',
|
|
22
|
+
...settings
|
|
50
23
|
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
}
|
|
24
|
+
const grantConfig = (0, utils_1.getGrantConfig)(authService);
|
|
25
|
+
const serviceOptions = (0, utils_1.getServiceOptions)(authService, oauthOptions);
|
|
26
|
+
const servicePath = `${grantConfig.defaults.prefix || 'oauth'}/:provider`;
|
|
27
|
+
app.use(servicePath, new service_1.OAuthService(authService, oauthOptions), serviceOptions);
|
|
28
|
+
const oauthService = app.service(servicePath);
|
|
29
|
+
oauthService.hooks({
|
|
30
|
+
around: { all: [(0, schema_1.resolveDispatch)(), (0, service_1.redirectHook)()] }
|
|
60
31
|
});
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const express = (settings = {}) => (app) => {
|
|
65
|
-
const options = utils_1.getDefaultSettings(app, settings);
|
|
66
|
-
app.configure(exports.setup(options));
|
|
67
|
-
app.configure(express_1.default(options));
|
|
32
|
+
if (typeof oauthService.publish === 'function') {
|
|
33
|
+
app.service(servicePath).publish(() => null);
|
|
34
|
+
}
|
|
68
35
|
};
|
|
69
|
-
exports.
|
|
70
|
-
exports.expressOauth = exports.express;
|
|
36
|
+
exports.oauth = oauth;
|
|
71
37
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,iDAAiD;AACjD,+CAAoD;AAEpD,yCAAwD;AAM3B,8FANpB,wBAAa,OAMoB;AAL1C,uCAAsD;AACtD,mCAA+E;AAE/E,MAAM,KAAK,GAAG,IAAA,qBAAW,EAAC,kCAAkC,CAAC,CAAA;AAItD,MAAM,KAAK,GAChB,CAAC,WAAwC,EAAE,EAAE,EAAE,CAC/C,CAAC,GAAgB,EAAE,EAAE;IACnB,MAAM,WAAW,GAAG,GAAG,CAAC,qBAAqB,CAAC,CAAC,CAAC,GAA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ors';
|
|
3
|
+
import { AuthenticationService } from '@feathersjs/authentication';
|
|
4
|
+
import { OauthSetupSettings } from './utils';
|
|
5
|
+
export declare type GrantResponse = {
|
|
6
|
+
location: string;
|
|
7
|
+
session: any;
|
|
8
|
+
state: any;
|
|
9
|
+
};
|
|
10
|
+
export declare type OAuthParams = Omit<Params, 'route'> & {
|
|
11
|
+
session: any;
|
|
12
|
+
state: Record<string, any>;
|
|
13
|
+
route: {
|
|
14
|
+
provider: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export declare class OAuthError extends FeathersError {
|
|
18
|
+
location: string;
|
|
19
|
+
constructor(message: string, data: any, location: string);
|
|
20
|
+
}
|
|
21
|
+
export declare const redirectHook: () => (context: HookContext, next: NextFunction) => Promise<void>;
|
|
22
|
+
export declare class OAuthService {
|
|
23
|
+
service: AuthenticationService;
|
|
24
|
+
settings: OauthSetupSettings;
|
|
25
|
+
grant: any;
|
|
26
|
+
constructor(service: AuthenticationService, settings: OauthSetupSettings);
|
|
27
|
+
handler(method: string, params: OAuthParams, body?: any, override?: string): Promise<GrantResponse>;
|
|
28
|
+
authenticate(params: OAuthParams, result: GrantResponse): Promise<{
|
|
29
|
+
location: string;
|
|
30
|
+
}>;
|
|
31
|
+
find(params: OAuthParams): Promise<GrantResponse>;
|
|
32
|
+
get(override: string, params: OAuthParams): Promise<{
|
|
33
|
+
location: string;
|
|
34
|
+
}>;
|
|
35
|
+
create(data: any, params: OAuthParams): Promise<GrantResponse>;
|
|
36
|
+
}
|
package/lib/service.js
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.OAuthService = exports.redirectHook = exports.OAuthError = void 0;
|
|
7
|
+
const commons_1 = require("@feathersjs/commons");
|
|
8
|
+
const errors_1 = require("@feathersjs/errors");
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
10
|
+
//@ts-ignore
|
|
11
|
+
const grant_1 = __importDefault(require("grant/lib/grant"));
|
|
12
|
+
const utils_1 = require("./utils");
|
|
13
|
+
const debug = (0, commons_1.createDebug)('@feathersjs/authentication-oauth/services');
|
|
14
|
+
class OAuthError extends errors_1.FeathersError {
|
|
15
|
+
constructor(message, data, location) {
|
|
16
|
+
super(message, 'NotAuthenticated', 401, 'not-authenticated', data);
|
|
17
|
+
this.location = location;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.OAuthError = OAuthError;
|
|
21
|
+
const redirectHook = () => async (context, next) => {
|
|
22
|
+
try {
|
|
23
|
+
await next();
|
|
24
|
+
const { location } = context.result;
|
|
25
|
+
debug(`oAuth redirect to ${location}`);
|
|
26
|
+
if (location) {
|
|
27
|
+
context.http = {
|
|
28
|
+
...context.http,
|
|
29
|
+
location
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
if (error.location) {
|
|
35
|
+
context.http = {
|
|
36
|
+
...context.http,
|
|
37
|
+
location: error.location
|
|
38
|
+
};
|
|
39
|
+
context.result = typeof error.toJSON === 'function' ? error.toJSON() : error;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
exports.redirectHook = redirectHook;
|
|
47
|
+
class OAuthService {
|
|
48
|
+
constructor(service, settings) {
|
|
49
|
+
this.service = service;
|
|
50
|
+
this.settings = settings;
|
|
51
|
+
const config = (0, utils_1.getGrantConfig)(service);
|
|
52
|
+
this.grant = (0, grant_1.default)({ config });
|
|
53
|
+
}
|
|
54
|
+
async handler(method, params, body, override) {
|
|
55
|
+
const { session, state, query, route: { provider } } = params;
|
|
56
|
+
const result = await this.grant({
|
|
57
|
+
params: { provider, override },
|
|
58
|
+
state: state.grant,
|
|
59
|
+
session: session.grant,
|
|
60
|
+
query,
|
|
61
|
+
method,
|
|
62
|
+
body
|
|
63
|
+
});
|
|
64
|
+
session.grant = result.session;
|
|
65
|
+
state.grant = result.state;
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
async authenticate(params, result) {
|
|
69
|
+
var _a, _b;
|
|
70
|
+
const name = params.route.provider;
|
|
71
|
+
const { linkStrategy, authService } = this.settings;
|
|
72
|
+
const { accessToken, grant, query = {}, redirect } = params.session;
|
|
73
|
+
const strategy = this.service.getStrategy(name);
|
|
74
|
+
const authParams = {
|
|
75
|
+
...params,
|
|
76
|
+
authStrategies: [name],
|
|
77
|
+
authentication: accessToken
|
|
78
|
+
? {
|
|
79
|
+
strategy: linkStrategy,
|
|
80
|
+
accessToken
|
|
81
|
+
}
|
|
82
|
+
: null,
|
|
83
|
+
query,
|
|
84
|
+
redirect
|
|
85
|
+
};
|
|
86
|
+
const payload = (grant === null || grant === void 0 ? void 0 : grant.response) || ((_a = result === null || result === void 0 ? void 0 : result.session) === null || _a === void 0 ? void 0 : _a.response) || ((_b = result === null || result === void 0 ? void 0 : result.state) === null || _b === void 0 ? void 0 : _b.response) || params.query;
|
|
87
|
+
const authentication = {
|
|
88
|
+
strategy: name,
|
|
89
|
+
...payload
|
|
90
|
+
};
|
|
91
|
+
try {
|
|
92
|
+
debug(`Calling ${authService}.create authentication with strategy ${name}`);
|
|
93
|
+
const authResult = await this.service.create(authentication, authParams);
|
|
94
|
+
debug('Successful oAuth authentication, sending response');
|
|
95
|
+
const location = await strategy.getRedirect(authResult, authParams);
|
|
96
|
+
if (typeof params.session.destroy === 'function') {
|
|
97
|
+
await params.session.destroy();
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
...authResult,
|
|
101
|
+
location
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
const location = await strategy.getRedirect(error, authParams);
|
|
106
|
+
const e = new OAuthError(error.message, error.data, location);
|
|
107
|
+
if (typeof params.session.destroy === 'function') {
|
|
108
|
+
await params.session.destroy();
|
|
109
|
+
}
|
|
110
|
+
e.stack = error.stack;
|
|
111
|
+
throw e;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
async find(params) {
|
|
115
|
+
const { session, query } = params;
|
|
116
|
+
const { feathers_token, redirect, ...restQuery } = query;
|
|
117
|
+
const handlerParams = {
|
|
118
|
+
...params,
|
|
119
|
+
query: restQuery
|
|
120
|
+
};
|
|
121
|
+
if (feathers_token) {
|
|
122
|
+
debug('Got feathers_token query parameter to link accounts', feathers_token);
|
|
123
|
+
session.accessToken = feathers_token;
|
|
124
|
+
}
|
|
125
|
+
session.redirect = redirect;
|
|
126
|
+
session.query = restQuery;
|
|
127
|
+
return this.handler('GET', handlerParams, {});
|
|
128
|
+
}
|
|
129
|
+
async get(override, params) {
|
|
130
|
+
const result = await this.handler('GET', params, {}, override);
|
|
131
|
+
if (override === 'callback') {
|
|
132
|
+
return this.authenticate(params, result);
|
|
133
|
+
}
|
|
134
|
+
return result;
|
|
135
|
+
}
|
|
136
|
+
async create(data, params) {
|
|
137
|
+
return this.handler('POST', params, data);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
exports.OAuthService = OAuthService;
|
|
141
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":";;;;;;AAAA,iDAAiD;AAEjD,+CAAkD;AAClD,6DAA6D;AAC7D,YAAY;AACZ,4DAAmC;AAGnC,mCAA4D;AAE5D,MAAM,KAAK,GAAG,IAAA,qBAAW,EAAC,2CAA2C,CAAC,CAAA;AAgBtE,MAAa,UAAW,SAAQ,sBAAa;IAC3C,YAAY,OAAe,EAAE,IAAS,EAAS,QAAgB;QAC7D,KAAK,CAAC,OAAO,EAAE,kBAAkB,EAAE,GAAG,EA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AAG,SAAS,EAAE,GAAG,KAAK,CAAA;QACxD,MAAM,aAAa,GAAG;YACpB,GAAG,MAAM;YACT,KAAK,EAAE,SAAS;SACjB,CAAA;QAED,IAAI,cAAc,EAAE;YAClB,KAAK,CAAC,qDAAqD,EAAE,cAAc,CAAC,CAAA;YAC5E,OAAO,CAAC,WAAW,GAAG,cAAc,CAAA;SACrC;QAED,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAA;QAC3B,OAAO,CAAC,KAAK,GAAG,SAAS,CAAA;QAEzB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE,CAAC,CAAA;IAC/C,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,QAAgB,EAAE,MAAmB;QAC7C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAA;QAE9D,IAAI,QAAQ,KAAK,UAAU,EAAE;YAC3B,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;SACzC;QAED,OAAO,MAAM,CAAA;IACf,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,IAAS,EAAE,MAAmB;QACzC,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,CAAA;IAC3C,CAAC;CACF;AArHD,oCAqHC"}
|
package/lib/strategy.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AuthenticationRequest, AuthenticationBaseStrategy, AuthenticationResult } from '@feathersjs/authentication';
|
|
1
|
+
import { AuthenticationRequest, AuthenticationBaseStrategy, AuthenticationResult, AuthenticationParams } from '@feathersjs/authentication';
|
|
2
2
|
import { Params } from '@feathersjs/feathers';
|
|
3
3
|
export interface OAuthProfile {
|
|
4
4
|
id?: string | number;
|
|
@@ -15,12 +15,13 @@ export declare class OAuthStrategy extends AuthenticationBaseStrategy {
|
|
|
15
15
|
}>;
|
|
16
16
|
getProfile(data: AuthenticationRequest, _params: Params): Promise<any>;
|
|
17
17
|
getCurrentEntity(params: Params): Promise<any>;
|
|
18
|
-
|
|
18
|
+
getAllowedOrigin(params?: Params): Promise<any>;
|
|
19
|
+
getRedirect(data: AuthenticationResult | Error, params?: AuthenticationParams): Promise<string | null>;
|
|
19
20
|
findEntity(profile: OAuthProfile, params: Params): Promise<any>;
|
|
20
21
|
createEntity(profile: OAuthProfile, params: Params): Promise<any>;
|
|
21
22
|
updateEntity(entity: any, profile: OAuthProfile, params: Params): Promise<any[]>;
|
|
22
23
|
getEntity(result: any, params: Params): Promise<any>;
|
|
23
|
-
authenticate(authentication: AuthenticationRequest, originalParams:
|
|
24
|
+
authenticate(authentication: AuthenticationRequest, originalParams: AuthenticationParams): Promise<{
|
|
24
25
|
[x: string]: any;
|
|
25
26
|
authentication: {
|
|
26
27
|
strategy: string;
|
package/lib/strategy.js
CHANGED
|
@@ -1,154 +1,130 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
-
var t = {};
|
|
13
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
-
t[p] = s[p];
|
|
15
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
-
t[p[i]] = s[p[i]];
|
|
19
|
-
}
|
|
20
|
-
return t;
|
|
21
|
-
};
|
|
22
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
4
|
};
|
|
25
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
6
|
exports.OAuthStrategy = void 0;
|
|
27
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
28
|
-
// @ts-ignore
|
|
29
|
-
const querystring_1 = __importDefault(require("querystring"));
|
|
30
7
|
const authentication_1 = require("@feathersjs/authentication");
|
|
31
8
|
const errors_1 = require("@feathersjs/errors");
|
|
32
9
|
const commons_1 = require("@feathersjs/commons");
|
|
33
|
-
const
|
|
10
|
+
const qs_1 = __importDefault(require("qs"));
|
|
11
|
+
const debug = (0, commons_1.createDebug)('@feathersjs/authentication-oauth/strategy');
|
|
34
12
|
class OAuthStrategy extends authentication_1.AuthenticationBaseStrategy {
|
|
35
13
|
get configuration() {
|
|
36
14
|
const { entity, service, entityId, oauth } = this.authentication.configuration;
|
|
37
15
|
const config = oauth[this.name];
|
|
38
|
-
return
|
|
16
|
+
return {
|
|
17
|
+
entity,
|
|
39
18
|
service,
|
|
40
|
-
entityId
|
|
19
|
+
entityId,
|
|
20
|
+
...config
|
|
21
|
+
};
|
|
41
22
|
}
|
|
42
23
|
get entityId() {
|
|
43
24
|
const { entityService } = this;
|
|
44
25
|
return this.configuration.entityId || (entityService && entityService.id);
|
|
45
26
|
}
|
|
46
|
-
getEntityQuery(profile, _params) {
|
|
47
|
-
return
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
};
|
|
51
|
-
});
|
|
27
|
+
async getEntityQuery(profile, _params) {
|
|
28
|
+
return {
|
|
29
|
+
[`${this.name}Id`]: profile.sub || profile.id
|
|
30
|
+
};
|
|
52
31
|
}
|
|
53
|
-
getEntityData(profile, _existingEntity, _params) {
|
|
54
|
-
return
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
};
|
|
58
|
-
});
|
|
32
|
+
async getEntityData(profile, _existingEntity, _params) {
|
|
33
|
+
return {
|
|
34
|
+
[`${this.name}Id`]: profile.sub || profile.id
|
|
35
|
+
};
|
|
59
36
|
}
|
|
60
|
-
getProfile(data, _params) {
|
|
61
|
-
return
|
|
62
|
-
return data.profile;
|
|
63
|
-
});
|
|
37
|
+
async getProfile(data, _params) {
|
|
38
|
+
return data.profile;
|
|
64
39
|
}
|
|
65
|
-
getCurrentEntity(params) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
return null;
|
|
77
|
-
});
|
|
40
|
+
async getCurrentEntity(params) {
|
|
41
|
+
const { authentication } = params;
|
|
42
|
+
const { entity } = this.configuration;
|
|
43
|
+
if (authentication && authentication.strategy) {
|
|
44
|
+
debug('getCurrentEntity with authentication', authentication);
|
|
45
|
+
const { strategy } = authentication;
|
|
46
|
+
const authResult = await this.authentication.authenticate(authentication, params, strategy);
|
|
47
|
+
return authResult[entity];
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
78
50
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
51
|
+
async getAllowedOrigin(params) {
|
|
52
|
+
var _a;
|
|
53
|
+
const { redirect, origins = this.app.get('origins') } = this.authentication.configuration.oauth;
|
|
54
|
+
if (Array.isArray(origins)) {
|
|
55
|
+
const referer = ((_a = params === null || params === void 0 ? void 0 : params.headers) === null || _a === void 0 ? void 0 : _a.referer) || origins[0];
|
|
56
|
+
const allowedOrigin = origins.find((current) => referer.toLowerCase().startsWith(current.toLowerCase()));
|
|
57
|
+
if (!allowedOrigin) {
|
|
58
|
+
throw new errors_1.NotAuthenticated(`Referer "${referer}" is not allowed.`);
|
|
85
59
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const authResult = data;
|
|
90
|
-
const query = authResult.accessToken ? {
|
|
91
|
-
access_token: authResult.accessToken
|
|
92
|
-
} : {
|
|
93
|
-
error: data.message || 'OAuth Authentication not successful'
|
|
94
|
-
};
|
|
95
|
-
return `${redirectUrl}${separator}${querystring_1.default.stringify(query)}`;
|
|
96
|
-
});
|
|
60
|
+
return allowedOrigin;
|
|
61
|
+
}
|
|
62
|
+
return redirect;
|
|
97
63
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
64
|
+
async getRedirect(data, params) {
|
|
65
|
+
const queryRedirect = (params && params.redirect) || '';
|
|
66
|
+
const redirect = await this.getAllowedOrigin(params);
|
|
67
|
+
if (!redirect) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
const redirectUrl = `${redirect}${queryRedirect}`;
|
|
71
|
+
const separator = redirect.endsWith('?') ? '' : redirect.indexOf('#') !== -1 ? '?' : '#';
|
|
72
|
+
const authResult = data;
|
|
73
|
+
const query = authResult.accessToken
|
|
74
|
+
? { access_token: authResult.accessToken }
|
|
75
|
+
: { error: data.message || 'OAuth Authentication not successful' };
|
|
76
|
+
return `${redirectUrl}${separator}${qs_1.default.stringify(query)}`;
|
|
107
77
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
78
|
+
async findEntity(profile, params) {
|
|
79
|
+
const query = await this.getEntityQuery(profile, params);
|
|
80
|
+
debug('findEntity with query', query);
|
|
81
|
+
const result = await this.entityService.find({
|
|
82
|
+
...params,
|
|
83
|
+
query
|
|
113
84
|
});
|
|
85
|
+
const [entity = null] = result.data ? result.data : result;
|
|
86
|
+
debug('findEntity returning', entity);
|
|
87
|
+
return entity;
|
|
114
88
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
debug(`updateEntity with id ${id} and data`, data);
|
|
120
|
-
return this.entityService.patch(id, data, params);
|
|
121
|
-
});
|
|
89
|
+
async createEntity(profile, params) {
|
|
90
|
+
const data = await this.getEntityData(profile, null, params);
|
|
91
|
+
debug('createEntity with data', data);
|
|
92
|
+
return this.entityService.create(data, commons_1._.omit(params, 'query'));
|
|
122
93
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
throw new errors_1.NotAuthenticated('Could not get oAuth entity');
|
|
129
|
-
}
|
|
130
|
-
if (!params.provider) {
|
|
131
|
-
return result;
|
|
132
|
-
}
|
|
133
|
-
return entityService.get(result[entityId], Object.assign(Object.assign({}, params), { [entity]: result }));
|
|
134
|
-
});
|
|
94
|
+
async updateEntity(entity, profile, params) {
|
|
95
|
+
const id = entity[this.entityId];
|
|
96
|
+
const data = await this.getEntityData(profile, entity, params);
|
|
97
|
+
debug(`updateEntity with id ${id} and data`, data);
|
|
98
|
+
return this.entityService.patch(id, data, commons_1._.omit(params, 'query'));
|
|
135
99
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
[entity]: yield this.getEntity(authEntity, originalParams)
|
|
149
|
-
};
|
|
100
|
+
async getEntity(result, params) {
|
|
101
|
+
const { entityService } = this;
|
|
102
|
+
const { entityId = entityService.id, entity } = this.configuration;
|
|
103
|
+
if (!entityId || result[entityId] === undefined) {
|
|
104
|
+
throw new errors_1.NotAuthenticated('Could not get oAuth entity');
|
|
105
|
+
}
|
|
106
|
+
if (!params.provider) {
|
|
107
|
+
return result;
|
|
108
|
+
}
|
|
109
|
+
return entityService.get(result[entityId], {
|
|
110
|
+
...commons_1._.omit(params, 'query'),
|
|
111
|
+
[entity]: result
|
|
150
112
|
});
|
|
151
113
|
}
|
|
114
|
+
async authenticate(authentication, originalParams) {
|
|
115
|
+
const entity = this.configuration.entity;
|
|
116
|
+
const { provider, ...params } = originalParams;
|
|
117
|
+
const profile = await this.getProfile(authentication, params);
|
|
118
|
+
const existingEntity = (await this.findEntity(profile, params)) || (await this.getCurrentEntity(params));
|
|
119
|
+
debug('authenticate with (existing) entity', existingEntity);
|
|
120
|
+
const authEntity = !existingEntity
|
|
121
|
+
? await this.createEntity(profile, params)
|
|
122
|
+
: await this.updateEntity(existingEntity, profile, params);
|
|
123
|
+
return {
|
|
124
|
+
authentication: { strategy: this.name },
|
|
125
|
+
[entity]: await this.getEntity(authEntity, originalParams)
|
|
126
|
+
};
|
|
127
|
+
}
|
|
152
128
|
}
|
|
153
129
|
exports.OAuthStrategy = OAuthStrategy;
|
|
154
130
|
//# sourceMappingURL=strategy.js.map
|
package/lib/strategy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strategy.js","sourceRoot":"","sources":["../src/strategy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"strategy.js","sourceRoot":"","sources":["../src/strategy.ts"],"names":[],"mappings":";;;;;;AAAA,+DAKmC;AAEnC,+CAAqD;AACrD,iDAAoD;AACpD,4CAAmB;AAEnB,MAAM,KAAK,GAAG,IAAA,qBAAW,EAAC,2CAA2C,CAAC,CAAA;AAOtE,MAAa,aAAc,SAAQ,2CAA0B;IAC3D,IAAI,aAAa;QACf,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,cAAc,CAAC,aAAa,CAAA;QAC9E,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAQ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M,CAAC,CAAA;QAC7D,MAAM,cAAc,GAAG,CAAC,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAA;QAExG,KAAK,CAAC,qCAAqC,EAAE,cAAc,CAAC,CAAA;QAE5D,MAAM,UAAU,GAAG,CAAC,cAAc;YAChC,CAAC,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC;YAC1C,CAAC,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,cAAc,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA;QAE5D,OAAO;YACL,cAAc,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE;YACvC,CAAC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,cAAc,CAAC;SAC3D,CAAA;IACH,CAAC;CACF;AA7JD,sCA6JC"}
|
package/lib/utils.d.ts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
import { RequestHandler } from 'express';
|
|
2
|
-
import {
|
|
1
|
+
import type { RequestHandler } from 'express';
|
|
2
|
+
import type { Middleware } from '@feathersjs/koa';
|
|
3
|
+
import type { ServiceOptions } from '@feathersjs/feathers';
|
|
4
|
+
import '@feathersjs/koa';
|
|
5
|
+
import '@feathersjs/express';
|
|
6
|
+
import { AuthenticationService } from '@feathersjs/authentication';
|
|
7
|
+
import { GrantConfig } from 'grant';
|
|
3
8
|
export interface OauthSetupSettings {
|
|
9
|
+
linkStrategy: string;
|
|
4
10
|
authService?: string;
|
|
5
11
|
expressSession?: RequestHandler;
|
|
6
|
-
|
|
12
|
+
koaSession?: Middleware;
|
|
7
13
|
}
|
|
8
|
-
export declare const
|
|
14
|
+
export declare const getGrantConfig: (service: AuthenticationService) => GrantConfig;
|
|
15
|
+
export declare const setExpressParams: RequestHandler;
|
|
16
|
+
export declare const setKoaParams: Middleware;
|
|
17
|
+
export declare const getServiceOptions: (service: AuthenticationService, settings: OauthSetupSettings) => ServiceOptions;
|