feat: Export AuthAdapter to make it available for extension with custom authentication adapters (#8443)
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import loadAdapter from '../AdapterLoader';
|
import loadAdapter from '../AdapterLoader';
|
||||||
import Parse from 'parse/node';
|
import Parse from 'parse/node';
|
||||||
|
import AuthAdapter from './AuthAdapter';
|
||||||
|
|
||||||
const apple = require('./apple');
|
const apple = require('./apple');
|
||||||
const gcenter = require('./gcenter');
|
const gcenter = require('./gcenter');
|
||||||
@@ -153,22 +154,30 @@ function loadAuthAdapter(provider, authOptions) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const adapter = Object.assign({}, defaultAdapter);
|
const adapter = defaultAdapter instanceof AuthAdapter ? defaultAdapter : Object.assign({}, defaultAdapter);
|
||||||
|
const keys = [
|
||||||
|
'validateAuthData',
|
||||||
|
'validateAppId',
|
||||||
|
'validateSetUp',
|
||||||
|
'validateLogin',
|
||||||
|
'validateUpdate',
|
||||||
|
'challenge',
|
||||||
|
'policy'
|
||||||
|
];
|
||||||
|
const defaultAuthAdapter = new AuthAdapter();
|
||||||
|
keys.forEach(key => {
|
||||||
|
const existing = adapter?.[key];
|
||||||
|
if (existing && typeof existing === 'function' && existing.toString() === defaultAuthAdapter[key].toString()) {
|
||||||
|
adapter[key] = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
const appIds = providerOptions ? providerOptions.appIds : undefined;
|
const appIds = providerOptions ? providerOptions.appIds : undefined;
|
||||||
|
|
||||||
// Try the configuration methods
|
// Try the configuration methods
|
||||||
if (providerOptions) {
|
if (providerOptions) {
|
||||||
const optionalAdapter = loadAdapter(providerOptions, undefined, providerOptions);
|
const optionalAdapter = loadAdapter(providerOptions, undefined, providerOptions);
|
||||||
if (optionalAdapter) {
|
if (optionalAdapter) {
|
||||||
[
|
keys.forEach(key => {
|
||||||
'validateAuthData',
|
|
||||||
'validateAppId',
|
|
||||||
'validateSetUp',
|
|
||||||
'validateLogin',
|
|
||||||
'validateUpdate',
|
|
||||||
'challenge',
|
|
||||||
'policy',
|
|
||||||
].forEach(key => {
|
|
||||||
if (optionalAdapter[key]) {
|
if (optionalAdapter[key]) {
|
||||||
adapter[key] = optionalAdapter[key];
|
adapter[key] = optionalAdapter[key];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import RedisCacheAdapter from './Adapters/Cache/RedisCacheAdapter';
|
|||||||
import LRUCacheAdapter from './Adapters/Cache/LRUCache.js';
|
import LRUCacheAdapter from './Adapters/Cache/LRUCache.js';
|
||||||
import * as TestUtils from './TestUtils';
|
import * as TestUtils from './TestUtils';
|
||||||
import * as SchemaMigrations from './SchemaMigrations/Migrations';
|
import * as SchemaMigrations from './SchemaMigrations/Migrations';
|
||||||
|
import AuthAdapter from './Adapters/Auth/AuthAdapter';
|
||||||
|
|
||||||
import { useExternal } from './deprecated';
|
import { useExternal } from './deprecated';
|
||||||
import { getLogger } from './logger';
|
import { getLogger } from './logger';
|
||||||
@@ -43,4 +44,5 @@ export {
|
|||||||
ParseGraphQLServer,
|
ParseGraphQLServer,
|
||||||
_ParseServer as ParseServer,
|
_ParseServer as ParseServer,
|
||||||
SchemaMigrations,
|
SchemaMigrations,
|
||||||
|
AuthAdapter,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user