diff --git a/src/server/auth/LdapAuth.ts b/src/server/auth/LdapAuth.ts index f526cec..7d2c900 100644 --- a/src/server/auth/LdapAuth.ts +++ b/src/server/auth/LdapAuth.ts @@ -19,6 +19,8 @@ export class LdapAuth implements Auth { try { await this.client.bind(`${this.domain}\\${username}`, password) + // const isAdmin = await this.isAdmin(username) + const search = await this.client.search(this.searchDN, { scope: 'sub', filter: `(sAMAccountName=${username})`, @@ -40,4 +42,23 @@ export class LdapAuth implements Auth { await this.client.unbind() } } + + async isAdmin(username: string): Promise { + const adminsGroupDN = ( + await this.client.search(this.searchDN, { + filter: `(&(objectCategory=group)(cn=PP-PTI-Admins))` + }) + ).searchEntries[0]?.distinguishedName as string + + const adminGroupMembers = await this.client.search(this.searchDN, { + filter: `(memberOf:1.2.840.113556.1.4.1941:=${adminsGroupDN})`, + attributes: ['sAMAccountName'] + }) + + const isAdmin = adminGroupMembers.searchEntries.some( + entry => entry.sAMAccountName === username + ) + + return isAdmin + } } diff --git a/src/web/router/index.ts b/src/web/router/index.ts index 62689d7..718c48a 100644 --- a/src/web/router/index.ts +++ b/src/web/router/index.ts @@ -16,6 +16,21 @@ const routes = [ import(/* webpackChunkName: "home" */ '@/views/Login.vue') } ] + }, + { + path: '/add-firewall', + component: () => import('@/layouts/default/Default.vue'), + children: [ + { + path: '', + name: 'AddFirewall', + + component: () => + import( + /* webpackChunkName: "addFirewall" */ '@/views/AddFirewall.vue' + ) + } + ] } ] diff --git a/src/web/views/AddFirewall.vue b/src/web/views/AddFirewall.vue new file mode 100644 index 0000000..e598902 --- /dev/null +++ b/src/web/views/AddFirewall.vue @@ -0,0 +1 @@ +