Fix #19 (defaultAccessRule type)

This commit is contained in:
Ewout Stortenbeker 2022-05-20 14:42:55 +02:00
parent b3fa70fa28
commit 7be8564221
2 changed files with 9 additions and 8 deletions

View file

@ -2,7 +2,7 @@ import { AceBase } from 'acebase';
import { DebugLogger, PathInfo } from 'acebase-core';
import * as fs from 'fs';
import { DbUserAccountDetails } from './schema/user';
import { AUTH_ACCESS_DEFAULT } from './settings';
import { AUTH_ACCESS_DEFAULT, AuthAccessDefault } from './settings';
type PathRuleFunction = ((env: any) => boolean) & { getText(): string };
type PathRules = {} & {
@ -24,7 +24,7 @@ export class PathBasedRules {
private accessRules: RulesData;
stop(): void { throw new Error('not started yet'); }
constructor(rulesFilePath: string, defaultAccess: AUTH_ACCESS_DEFAULT, env: { debug: DebugLogger, db: AceBase, authEnabled: boolean } ) {
constructor(rulesFilePath: string, defaultAccess: AuthAccessDefault, env: { debug: DebugLogger, db: AceBase, authEnabled: boolean } ) {
// Reads rules from a file and monitors it
// Check if there is a rules file, load it or generate default

View file

@ -35,11 +35,12 @@ export class AceBaseServerHttpsConfig {
}
}
export enum AUTH_ACCESS_DEFAULT {
DENY_ALL = 'deny',
ALLOW_ALL = 'allow',
ALLOW_AUTHENTICATED = 'auth'
}
export type AuthAccessDefault = 'deny'|'allow'|'auth';
export const AUTH_ACCESS_DEFAULT: { [key: string]: AuthAccessDefault } = {
DENY_ALL: 'deny',
ALLOW_ALL: 'allow',
ALLOW_AUTHENTICATED: 'auth'
};
export class AceBaseServerAuthenticationSettings {
@ -66,7 +67,7 @@ export class AceBaseServerAuthenticationSettings {
/**
* When the server runs for the first time, what defaults to use to generate the rules.json file with. Options are: 'auth' (only authenticated access to db, default), 'deny' (deny access to anyone except admin user), 'allow' (allow access to anyone)
*/
readonly defaultAccessRule: AUTH_ACCESS_DEFAULT = AUTH_ACCESS_DEFAULT.ALLOW_AUTHENTICATED;
readonly defaultAccessRule: AuthAccessDefault = AUTH_ACCESS_DEFAULT.ALLOW_AUTHENTICATED;
/**
* When the server runs for the first time, what password to use for the admin user. If not supplied, a generated password will be used and shown ONCE in the console output.