chore: expose auth manager option in application (#2894)
This commit is contained in:
parent
b18822aaa9
commit
d751b30b34
@ -9,7 +9,7 @@ type Storer = {
|
||||
get: (name: string) => Promise<Model>;
|
||||
};
|
||||
|
||||
type AuthManagerOptions = {
|
||||
export type AuthManagerOptions = {
|
||||
authKey: string;
|
||||
default?: string;
|
||||
jwt?: JwtOptions;
|
||||
@ -21,11 +21,11 @@ type AuthConfig = {
|
||||
};
|
||||
|
||||
export class AuthManager {
|
||||
jwt: JwtService;
|
||||
protected options: AuthManagerOptions;
|
||||
protected authTypes: Registry<AuthConfig> = new Registry();
|
||||
// authenticators collection manager.
|
||||
protected storer: Storer;
|
||||
jwt: JwtService;
|
||||
|
||||
constructor(options: AuthManagerOptions) {
|
||||
this.options = options;
|
||||
|
@ -1,11 +1,11 @@
|
||||
import { ACL } from '@nocobase/acl';
|
||||
import { registerActions } from '@nocobase/actions';
|
||||
import { actions as authActions, AuthManager } from '@nocobase/auth';
|
||||
import { actions as authActions, AuthManager, AuthManagerOptions } from '@nocobase/auth';
|
||||
import { Cache, createCache, ICacheConfig } from '@nocobase/cache';
|
||||
import Database, { CollectionOptions, IDatabaseOptions } from '@nocobase/database';
|
||||
import { AppLoggerOptions, createAppLogger, Logger } from '@nocobase/logger';
|
||||
import { ResourceOptions, Resourcer } from '@nocobase/resourcer';
|
||||
import { applyMixins, AsyncEmitter, Toposort, ToposortOptions, measureExecutionTime } from '@nocobase/utils';
|
||||
import { applyMixins, AsyncEmitter, measureExecutionTime, Toposort, ToposortOptions } from '@nocobase/utils';
|
||||
import chalk from 'chalk';
|
||||
import { Command, CommandOptions, ParseOptions } from 'commander';
|
||||
import { IncomingMessage, Server, ServerResponse } from 'http';
|
||||
@ -23,7 +23,6 @@ import { ApplicationVersion } from './helpers/application-version';
|
||||
import { Locale } from './locale';
|
||||
import { Plugin } from './plugin';
|
||||
import { InstallOptions, PluginManager } from './plugin-manager';
|
||||
import { CronJob } from 'cron';
|
||||
import { CronJobManager } from './cron/cron-job-manager';
|
||||
|
||||
const packageJson = require('../package.json');
|
||||
@ -49,6 +48,7 @@ export interface ApplicationOptions {
|
||||
logger?: AppLoggerOptions;
|
||||
pmSock?: string;
|
||||
name?: string;
|
||||
authManager?: AuthManagerOptions;
|
||||
}
|
||||
|
||||
export interface DefaultState extends KoaDefaultState {
|
||||
@ -723,6 +723,7 @@ export class Application<StateT = DefaultState, ContextT = DefaultContext> exten
|
||||
this._authManager = new AuthManager({
|
||||
authKey: 'X-Authenticator',
|
||||
default: 'basic',
|
||||
...(this.options.authManager || {}),
|
||||
});
|
||||
|
||||
this.resource({
|
||||
|
Loading…
Reference in New Issue
Block a user