Added isAdmin
This commit is contained in:
parent
9c23047de3
commit
70112c2b33
|
@ -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<boolean> {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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'
|
||||
)
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
|
|
1
src/web/views/AddFirewall.vue
Normal file
1
src/web/views/AddFirewall.vue
Normal file
|
@ -0,0 +1 @@
|
|||
<template>test</template>
|
Loading…
Reference in New Issue
Block a user