1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-31 00:16:47 +01:00
unleash.unleash/src/lib/routes/admin-api/config.ts
Ivar Conradi Østhus 4fb1bcb524
feat: Disable password based login (#1046)
This commit will introduce a new setting used to disbaled
simple password based authention.

The setting itself is an enterprise setting.
2021-10-29 10:25:42 +02:00

54 lines
1.7 KiB
TypeScript

import { Request, Response } from 'express';
import { IUnleashServices } from '../../types/services';
import { IUnleashConfig } from '../../types/option';
import version from '../../util/version';
import Controller from '../controller';
import VersionService from '../../services/version-service';
import SettingService from '../../services/setting-service';
import {
simpleAuthKey,
SimpleAuthSettings,
} from '../../types/settings/simple-auth-settings';
class ConfigController extends Controller {
private versionService: VersionService;
private settingService: SettingService;
private uiConfig: any;
constructor(
config: IUnleashConfig,
{
versionService,
settingService,
}: Pick<IUnleashServices, 'versionService' | 'settingService'>,
) {
super(config);
this.versionService = versionService;
this.settingService = settingService;
const authenticationType =
config.authentication && config.authentication.type;
this.uiConfig = {
...config.ui,
authenticationType,
unleashUrl: config.server.unleashUrl,
baseUriPath: config.server.baseUriPath,
version,
};
this.get('/', this.getUIConfig);
}
async getUIConfig(req: Request, res: Response): Promise<void> {
const config = this.uiConfig;
const simpleAuthSettings =
await this.settingService.get<SimpleAuthSettings>(simpleAuthKey);
const versionInfo = this.versionService.getVersionInfo();
const disablePasswordAuth = simpleAuthSettings?.disabled;
res.json({ ...config, versionInfo, disablePasswordAuth });
}
}
export default ConfigController;