diff --git a/src/rules.ts b/src/rules.ts index 3ea5146..ee31fb5 100644 --- a/src/rules.ts +++ b/src/rules.ts @@ -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 diff --git a/src/settings/index.ts b/src/settings/index.ts index aef95ac..d1bd1e7 100644 --- a/src/settings/index.ts +++ b/src/settings/index.ts @@ -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.