mirror of
https://github.com/strapi/strapi.git
synced 2025-11-08 06:07:41 +00:00
fix dynamic callback
This commit is contained in:
parent
5cdd3f0044
commit
e230827335
@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
const { defaultsDeep, isEmpty, omit, has } = require('lodash/fp');
|
const { defaultsDeep, isEmpty, isString, omit, has } = require('lodash/fp');
|
||||||
const session = require('koa-session');
|
const session = require('koa-session');
|
||||||
|
|
||||||
const defaultConfig = {
|
const defaultConfig = {
|
||||||
@ -22,7 +22,9 @@ module.exports = (userConfig, { strapi }) => {
|
|||||||
let secretKeys = [];
|
let secretKeys = [];
|
||||||
|
|
||||||
if (has('secretKeys', userConfig)) {
|
if (has('secretKeys', userConfig)) {
|
||||||
secretKeys = userConfig.secretKeys;
|
secretKeys = isString(userConfig.secretKeys)
|
||||||
|
? userConfig.secretKeys.split(',')
|
||||||
|
: userConfig.secretKeys;
|
||||||
} else if (has('SESSION_SECRET_KEYS', process.env)) {
|
} else if (has('SESSION_SECRET_KEYS', process.env)) {
|
||||||
secretKeys = process.env.SESSION_SECRET_KEYS.split(',');
|
secretKeys = process.env.SESSION_SECRET_KEYS.split(',');
|
||||||
} else {
|
} else {
|
||||||
@ -38,7 +40,6 @@ module.exports = (userConfig, { strapi }) => {
|
|||||||
|
|
||||||
strapi.server.app.keys = secretKeys;
|
strapi.server.app.keys = secretKeys;
|
||||||
}
|
}
|
||||||
|
|
||||||
const config = defaultsDeep(defaultConfig, omit('secretKeys', userConfig));
|
const config = defaultsDeep(defaultConfig, omit('secretKeys', userConfig));
|
||||||
|
|
||||||
strapi.server.use(session(config, strapi.server.app));
|
strapi.server.use(session(config, strapi.server.app));
|
||||||
|
|||||||
@ -188,7 +188,10 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ability to pass OAuth callback dynamically
|
// Ability to pass OAuth callback dynamically
|
||||||
grantConfig[provider].callback = _.get(ctx, 'query.callback') || grantConfig[provider].callback;
|
grantConfig[provider].callback =
|
||||||
|
_.get(ctx, 'query.callback') ||
|
||||||
|
_.get(ctx, 'session.grant.dynamic.callback') ||
|
||||||
|
grantConfig[provider].callback;
|
||||||
grantConfig[provider].redirect_uri = getService('providers').buildRedirectUri(provider);
|
grantConfig[provider].redirect_uri = getService('providers').buildRedirectUri(provider);
|
||||||
|
|
||||||
return grant(grantConfig)(ctx, next);
|
return grant(grantConfig)(ctx, next);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user