@feathersjs/authentication-oauth
Advanced tools
Comparing version 4.3.11 to 4.4.0
@@ -6,2 +6,13 @@ # Change Log | ||
# [4.4.0](https://github.com/feathersjs/feathers/compare/v4.3.11...v4.4.0) (2019-11-27) | ||
### Features | ||
* **authentication-oauth:** Set oAuth redirect URL dynamically ([#1608](https://github.com/feathersjs/feathers/issues/1608)) ([1293e08](https://github.com/feathersjs/feathers/commit/1293e088abbb3d23f4a44680836645a8049ceaae)) | ||
## [4.3.11](https://github.com/feathersjs/feathers/compare/v4.3.10...v4.3.11) (2019-11-11) | ||
@@ -8,0 +19,0 @@ |
@@ -58,2 +58,3 @@ "use strict"; | ||
req.session.accessToken = feathers_token; | ||
req.session.query = query; | ||
} | ||
@@ -67,8 +68,16 @@ res.redirect(`${path}/connect/${name}?${querystring_1.default.stringify(query)}`); | ||
const { name } = req.params; | ||
const { accessToken, grant } = req.session; | ||
const { accessToken, grant, query = {} } = req.session; | ||
const service = app.defaultAuthentication(authService); | ||
const [strategy] = service.getStrategies(name); | ||
const params = { | ||
authStrategies: [name], | ||
authentication: accessToken ? { | ||
strategy: linkStrategy, | ||
accessToken | ||
} : null, | ||
query | ||
}; | ||
const sendResponse = (data) => __awaiter(void 0, void 0, void 0, function* () { | ||
try { | ||
const redirect = yield strategy.getRedirect(data); | ||
const redirect = yield strategy.getRedirect(data, params); | ||
if (redirect !== null) { | ||
@@ -92,9 +101,2 @@ res.redirect(redirect); | ||
grant.response : req.query; | ||
const params = { | ||
authStrategies: [name], | ||
authentication: accessToken ? { | ||
strategy: linkStrategy, | ||
accessToken | ||
} : null | ||
}; | ||
const authentication = Object.assign({ strategy: name }, payload); | ||
@@ -101,0 +103,0 @@ debug(`Calling ${authService}.create authentication with strategy ${name}`); |
@@ -18,3 +18,3 @@ import { AuthenticationRequest, AuthenticationBaseStrategy, AuthenticationResult } from '@feathersjs/authentication'; | ||
getCurrentEntity(params: Params): Promise<any>; | ||
getRedirect(data: AuthenticationResult | Error): Promise<string>; | ||
getRedirect(data: AuthenticationResult | Error, params?: Params): Promise<string>; | ||
findEntity(profile: OAuthProfile, params: Params): Promise<any>; | ||
@@ -21,0 +21,0 @@ createEntity(profile: OAuthProfile, params: Params): Promise<any>; |
@@ -70,4 +70,5 @@ "use strict"; | ||
} | ||
getRedirect(data) { | ||
getRedirect(data, params) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const queryRedirect = (params && params.query && params.query.redirect) || ''; | ||
const { redirect } = this.authentication.configuration.oauth; | ||
@@ -77,2 +78,3 @@ if (!redirect) { | ||
} | ||
const redirectUrl = redirect + queryRedirect; | ||
const separator = redirect.endsWith('?') ? '' : | ||
@@ -86,3 +88,3 @@ (redirect.indexOf('#') !== -1 ? '?' : '#'); | ||
}; | ||
return redirect + separator + querystring_1.default.stringify(query); | ||
return redirectUrl + separator + querystring_1.default.stringify(query); | ||
}); | ||
@@ -89,0 +91,0 @@ } |
{ | ||
"name": "@feathersjs/authentication-oauth", | ||
"description": "oAuth 1 and 2 authentication for Feathers. Powered by Grant.", | ||
"version": "4.3.11", | ||
"version": "4.4.0", | ||
"homepage": "https://feathersjs.com", | ||
@@ -31,3 +31,3 @@ "main": "lib/", | ||
"engines": { | ||
"node": ">= 6" | ||
"node": ">= 12" | ||
}, | ||
@@ -47,6 +47,6 @@ "scripts": { | ||
"dependencies": { | ||
"@feathersjs/authentication": "^4.3.11", | ||
"@feathersjs/errors": "^4.3.11", | ||
"@feathersjs/express": "^4.3.11", | ||
"@feathersjs/feathers": "^4.3.11", | ||
"@feathersjs/authentication": "^4.4.0", | ||
"@feathersjs/errors": "^4.4.0", | ||
"@feathersjs/express": "^4.4.0", | ||
"@feathersjs/feathers": "^4.4.0", | ||
"debug": "^4.1.1", | ||
@@ -71,3 +71,3 @@ "express-session": "^1.17.0", | ||
}, | ||
"gitHead": "2d95bfd7a7cf064ef95925649b45b3ebecdb86c4" | ||
"gitHead": "e157e5f1e149a843377cb38f0a72ac191ecc3b45" | ||
} |
@@ -47,2 +47,3 @@ // @ts-ignore | ||
req.session.accessToken = feathers_token; | ||
req.session.query = query; | ||
} | ||
@@ -59,8 +60,16 @@ | ||
const { name } = req.params as any; | ||
const { accessToken, grant } = req.session; | ||
const { accessToken, grant, query = {} } = req.session; | ||
const service = app.defaultAuthentication(authService); | ||
const [ strategy ] = service.getStrategies(name) as OAuthStrategy[]; | ||
const params = { | ||
authStrategies: [ name ], | ||
authentication: accessToken ? { | ||
strategy: linkStrategy, | ||
accessToken | ||
} : null, | ||
query | ||
}; | ||
const sendResponse = async (data: AuthenticationResult|Error) => { | ||
try { | ||
const redirect = await strategy.getRedirect(data); | ||
const redirect = await strategy.getRedirect(data, params); | ||
@@ -83,11 +92,2 @@ if (redirect !== null) { | ||
grant.response : req.query; | ||
const params = { | ||
authStrategies: [ name ], | ||
authentication: accessToken ? { | ||
strategy: linkStrategy, | ||
accessToken | ||
} : null | ||
}; | ||
const authentication = { | ||
@@ -94,0 +94,0 @@ strategy: name, |
@@ -75,3 +75,4 @@ // @ts-ignore | ||
async getRedirect (data: AuthenticationResult|Error) { | ||
async getRedirect (data: AuthenticationResult|Error, params?: Params) { | ||
const queryRedirect = (params && params.query && params.query.redirect) || ''; | ||
const { redirect } = this.authentication.configuration.oauth; | ||
@@ -83,2 +84,3 @@ | ||
const redirectUrl = redirect + queryRedirect; | ||
const separator = redirect.endsWith('?') ? '' : | ||
@@ -93,3 +95,3 @@ (redirect.indexOf('#') !== -1 ? '?' : '#'); | ||
return redirect + separator + querystring.stringify(query); | ||
return redirectUrl + separator + querystring.stringify(query); | ||
} | ||
@@ -96,0 +98,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
266009
1658
Updated@feathersjs/errors@^4.4.0
Updated@feathersjs/express@^4.4.0
Updated@feathersjs/feathers@^4.4.0