|
@@ -1,108 +1,120 @@
|
|
|
|
|
|
|
|
export class LDAPAttribute {
|
|
export class LDAPAttribute {
|
|
|
- constructor(config: any) {
|
|
|
|
|
- this.name = config["name"];
|
|
|
|
|
- this.type = config["type"];
|
|
|
|
|
- this.mapped = config["mapped"];
|
|
|
|
|
- this.filter = config["filter"] ? new RegExp(config["filter"]) : null;
|
|
|
|
|
- }
|
|
|
|
|
- public readonly name: string;
|
|
|
|
|
- public readonly type: string;
|
|
|
|
|
- public readonly mapped: string;
|
|
|
|
|
- public readonly filter: RegExp | null;
|
|
|
|
|
|
|
+ constructor(config: any) {
|
|
|
|
|
+ this.name = config["name"];
|
|
|
|
|
+ this.type = config["type"];
|
|
|
|
|
+ this.mapped = config["mapped"];
|
|
|
|
|
+ this.filter = config["filter"] ? new RegExp(config["filter"]) : null;
|
|
|
|
|
+ }
|
|
|
|
|
+ public readonly name: string;
|
|
|
|
|
+ public readonly type: string;
|
|
|
|
|
+ public readonly mapped: string;
|
|
|
|
|
+ public readonly filter: RegExp | null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
export class LDAPCategory {
|
|
export class LDAPCategory {
|
|
|
- constructor(config: any) {
|
|
|
|
|
- this.fName = config["name"];
|
|
|
|
|
- this.fBase = config["base"];
|
|
|
|
|
- this.fScope = config["scope"];
|
|
|
|
|
- this.fAttributes = new Array();
|
|
|
|
|
- this.fFilter = config["filter"] || null;
|
|
|
|
|
- for (let i of config["attributes"])
|
|
|
|
|
- this.fAttributes.push(new LDAPAttribute(i));
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ constructor(config: any) {
|
|
|
|
|
+ this.fName = config["name"];
|
|
|
|
|
+ this.fBase = config["base"];
|
|
|
|
|
+ this.fScope = config["scope"];
|
|
|
|
|
+ this.fAttributes = new Array();
|
|
|
|
|
+ this.fFilter = config["filter"] || null;
|
|
|
|
|
+ for (let i of config["attributes"])
|
|
|
|
|
+ this.fAttributes.push(new LDAPAttribute(i));
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- public GetBaseDn(): string { return this.fBase; }
|
|
|
|
|
- public GetScope(): string { return this.fScope; }
|
|
|
|
|
- public GetName(): string { return this.fName; }
|
|
|
|
|
- public GetFilter(): string|null { return this.fFilter; }
|
|
|
|
|
- public GetAttributes(): Array<LDAPAttribute> { return this.fAttributes; }
|
|
|
|
|
|
|
+ public GetBaseDn(): string { return this.fBase; }
|
|
|
|
|
+ public GetScope(): string { return this.fScope; }
|
|
|
|
|
+ public GetName(): string { return this.fName; }
|
|
|
|
|
+ public GetFilter(): string|null { return this.fFilter; }
|
|
|
|
|
+ public GetAttributes(): Array<LDAPAttribute> { return this.fAttributes; }
|
|
|
|
|
|
|
|
- private fName: string;
|
|
|
|
|
- private fBase: string;
|
|
|
|
|
- private fScope: string;
|
|
|
|
|
- private fFilter: string|null;
|
|
|
|
|
- private fAttributes: Array<LDAPAttribute>;
|
|
|
|
|
|
|
+ private fName: string;
|
|
|
|
|
+ private fBase: string;
|
|
|
|
|
+ private fScope: string;
|
|
|
|
|
+ private fFilter: string|null;
|
|
|
|
|
+ private fAttributes: Array<LDAPAttribute>;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
export interface IConfigLoader {
|
|
export interface IConfigLoader {
|
|
|
- GetCategories(): Array<LDAPCategory>;
|
|
|
|
|
- GetCategoryByName(name: string): LDAPCategory | null;
|
|
|
|
|
- GetLDAPRoot(): string;
|
|
|
|
|
- GetLDAPUrls(): Array<string>;
|
|
|
|
|
- GetBindDn(): string;
|
|
|
|
|
- GetBindPassword(): string;
|
|
|
|
|
- GetNoLogin(): boolean;
|
|
|
|
|
- GetLoginBase(): string;
|
|
|
|
|
- GetLoginScope(): string;
|
|
|
|
|
- GetLoginFilter(username: string): string;
|
|
|
|
|
|
|
+ GetCategories(): Array<LDAPCategory>;
|
|
|
|
|
+ GetCategoryByName(name: string): LDAPCategory | null;
|
|
|
|
|
+ GetLDAPRoot(): string;
|
|
|
|
|
+ GetLDAPUrls(): Array<string>;
|
|
|
|
|
+ GetLDAPEditLinks(): Map<string, Array<string>>;
|
|
|
|
|
+ GetBindDn(): string;
|
|
|
|
|
+ GetBindPassword(): string;
|
|
|
|
|
+ GetNoLogin(): boolean;
|
|
|
|
|
+ GetLoginBase(): string;
|
|
|
|
|
+ GetLoginScope(): string;
|
|
|
|
|
+ GetLoginFilter(username: string): string;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
class ConfigLoader implements IConfigLoader {
|
|
class ConfigLoader implements IConfigLoader {
|
|
|
- public constructor(config: any) {
|
|
|
|
|
- this.fCategories = new Array();
|
|
|
|
|
- for (let i of config.LDAP_CATEGORIES) {
|
|
|
|
|
- this.fCategories.push(new LDAPCategory(i));
|
|
|
|
|
- }
|
|
|
|
|
- this.fServer.root = config["LDAP_ROOT"];
|
|
|
|
|
- this.fServer.urls = typeof config["LDAP_URL"] === "string" ? [config["LDAP_URL"]] : config["LDAP_URL"];
|
|
|
|
|
- this.fServer.bindDn = config["LDAP_BIND_DN"];
|
|
|
|
|
- this.fServer.bindPassword = config["LDAP_BIND_PASSWD"];
|
|
|
|
|
|
|
+ public constructor(config: any) {
|
|
|
|
|
+ this.fCategories = new Array();
|
|
|
|
|
+ for (let i of config.LDAP_CATEGORIES) {
|
|
|
|
|
+ this.fCategories.push(new LDAPCategory(i));
|
|
|
|
|
+ }
|
|
|
|
|
+ this.fEditLinks = new Map();
|
|
|
|
|
+ for (let i in config.EDIT_LINKS) {
|
|
|
|
|
+ this.fEditLinks.set(i, new Array());
|
|
|
|
|
+ for (let j of config.EDIT_LINKS[i])
|
|
|
|
|
+ this.fEditLinks.get(i)?.push(j);
|
|
|
|
|
+ }
|
|
|
|
|
+ this.fServer.root = config["LDAP_ROOT"];
|
|
|
|
|
+ this.fServer.urls = typeof config["LDAP_URL"] === "string" ? [config["LDAP_URL"]] : config["LDAP_URL"];
|
|
|
|
|
+ this.fServer.bindDn = config["LDAP_BIND_DN"];
|
|
|
|
|
+ this.fServer.bindPassword = config["LDAP_BIND_PASSWD"];
|
|
|
|
|
|
|
|
- this.fLogin.fBase = config["LDAP_LOGIN_BASE"];
|
|
|
|
|
- this.fLogin.fScope = config["LDAP_LOGIN_SCOPE"];
|
|
|
|
|
- this.fLogin.fFilter = config["LDAP_LOGIN_FILTER"];
|
|
|
|
|
|
|
+ this.fLogin.fBase = config["LDAP_LOGIN_BASE"];
|
|
|
|
|
+ this.fLogin.fScope = config["LDAP_LOGIN_SCOPE"];
|
|
|
|
|
+ this.fLogin.fFilter = config["LDAP_LOGIN_FILTER"];
|
|
|
|
|
|
|
|
- this.fNoLogin = !!config["NOLOGIN"];
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ this.fNoLogin = !!config["NOLOGIN"];
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- public GetLDAPRoot(): string { return this.fServer.root; }
|
|
|
|
|
- public GetLDAPUrls(): Array<string> { return this.fServer.urls; }
|
|
|
|
|
- public GetBindDn(): string { return this.fServer.bindDn; }
|
|
|
|
|
- public GetBindPassword(): string { return this.fServer.bindPassword; }
|
|
|
|
|
|
|
+ public GetLDAPRoot(): string { return this.fServer.root; }
|
|
|
|
|
+ public GetLDAPUrls(): Array<string> { return this.fServer.urls; }
|
|
|
|
|
+ public GetBindDn(): string { return this.fServer.bindDn; }
|
|
|
|
|
+ public GetBindPassword(): string { return this.fServer.bindPassword; }
|
|
|
|
|
|
|
|
- public GetCategories(): Array<LDAPCategory> { return this.fCategories; }
|
|
|
|
|
- public GetCategoryByName(name: string): LDAPCategory | null {
|
|
|
|
|
- for (let i of this.fCategories)
|
|
|
|
|
- if (i.GetName() === name)
|
|
|
|
|
- return i;
|
|
|
|
|
- return null;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ public GetLDAPEditLinks(): Map<string, Array<string>> {
|
|
|
|
|
+ return this.fEditLinks;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- public GetLoginBase(): string { return this.fLogin.fBase; }
|
|
|
|
|
- public GetLoginScope(): string { return this.fLogin.fScope; }
|
|
|
|
|
- public GetLoginFilter(login: string): string { return this.fLogin.fFilter(login); }
|
|
|
|
|
- public GetNoLogin(): boolean { return this.fNoLogin; }
|
|
|
|
|
|
|
+ public GetCategories(): Array<LDAPCategory> { return this.fCategories; }
|
|
|
|
|
+ public GetCategoryByName(name: string): LDAPCategory | null {
|
|
|
|
|
+ for (let i of this.fCategories)
|
|
|
|
|
+ if (i.GetName() === name)
|
|
|
|
|
+ return i;
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- private fCategories: Array<LDAPCategory>;
|
|
|
|
|
- private fNoLogin: boolean = false;
|
|
|
|
|
- private fServer = {
|
|
|
|
|
- urls: [],
|
|
|
|
|
- root: "",
|
|
|
|
|
- bindDn: "",
|
|
|
|
|
- bindPassword: ""
|
|
|
|
|
- };
|
|
|
|
|
- private fLogin = {
|
|
|
|
|
- fBase: "",
|
|
|
|
|
- fScope: "one",
|
|
|
|
|
- fFilter: (username: string):string => ""
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ public GetLoginBase(): string { return this.fLogin.fBase; }
|
|
|
|
|
+ public GetLoginScope(): string { return this.fLogin.fScope; }
|
|
|
|
|
+ public GetLoginFilter(login: string): string { return this.fLogin.fFilter(login); }
|
|
|
|
|
+ public GetNoLogin(): boolean { return this.fNoLogin; }
|
|
|
|
|
+
|
|
|
|
|
+ private fCategories: Array<LDAPCategory>;
|
|
|
|
|
+ private fEditLinks: Map<string, Array<string>>;
|
|
|
|
|
+ private fNoLogin: boolean = false;
|
|
|
|
|
+ private fServer = {
|
|
|
|
|
+ urls: [],
|
|
|
|
|
+ root: "",
|
|
|
|
|
+ bindDn: "",
|
|
|
|
|
+ bindPassword: ""
|
|
|
|
|
+ };
|
|
|
|
|
+ private fLogin = {
|
|
|
|
|
+ fBase: "",
|
|
|
|
|
+ fScope: "one",
|
|
|
|
|
+ fFilter: (username: string):string => ""
|
|
|
|
|
+ };
|
|
|
}
|
|
}
|
|
|
let _instance: IConfigLoader = new ConfigLoader(require("../config.js"));
|
|
let _instance: IConfigLoader = new ConfigLoader(require("../config.js"));
|
|
|
|
|
|
|
|
export default class ConfigManager {
|
|
export default class ConfigManager {
|
|
|
- public static GetInstance(): IConfigLoader {
|
|
|
|
|
- return _instance;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ public static GetInstance(): IConfigLoader {
|
|
|
|
|
+ return _instance;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|