fix dynamic callback

This commit is contained in:
Pierre Noël 2021-12-21 12:12:55 +01:00
parent 5cdd3f0044
commit e230827335
2 changed files with 8 additions and 4 deletions

View File

@ -1,7 +1,7 @@
'use strict';
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 defaultConfig = {
@ -22,7 +22,9 @@ module.exports = (userConfig, { strapi }) => {
let secretKeys = [];
if (has('secretKeys', userConfig)) {
secretKeys = userConfig.secretKeys;
secretKeys = isString(userConfig.secretKeys)
? userConfig.secretKeys.split(',')
: userConfig.secretKeys;
} else if (has('SESSION_SECRET_KEYS', process.env)) {
secretKeys = process.env.SESSION_SECRET_KEYS.split(',');
} else {
@ -38,7 +40,6 @@ module.exports = (userConfig, { strapi }) => {
strapi.server.app.keys = secretKeys;
}
const config = defaultsDeep(defaultConfig, omit('secretKeys', userConfig));
strapi.server.use(session(config, strapi.server.app));

View File

@ -188,7 +188,10 @@ module.exports = {
}
// 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);
return grant(grantConfig)(ctx, next);