Make UID case-insensitive
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-10-18 23:27:23 -05:00
parent 2d97b77bbf
commit 97096f619f
14 changed files with 32 additions and 31 deletions

View File

@@ -173,7 +173,7 @@ class User extends AuthUser {
const Policy = this.models.get('iam:Policy')
const ldap_data = {
uid: this.uid,
uid: this.uid.toLowerCase(),
uuid: this.uuid,
cn: this.first_name,
sn: this.last_name,
@@ -213,7 +213,7 @@ class User extends AuthUser {
}
get dn() {
return LDAP.parseDN(`uid=${this.uid},${this.ldap_server.auth_dn().format(this.configs.get('ldap:server.format'))}`)
return LDAP.parseDN(`uid=${this.uid.toLowerCase()},${this.ldap_server.auth_dn().format(this.configs.get('ldap:server.format'))}`)
}
// The following are used by OpenID connect
@@ -227,15 +227,15 @@ class User extends AuthUser {
given_name: this.first_name,
locale: 'en_US', // TODO
name: `${this.first_name} ${this.last_name}`,
preferred_username: this.uid,
username: this.uid,
preferred_username: this.uid.toLowerCase(),
username: this.uid.toLowerCase(),
}
}
static async findByLogin(login) {
return this.findOne({
active: true,
uid: login,
uid: login.toLowerCase(),
})
}

View File

@@ -118,7 +118,7 @@ class PolicyModel extends Model {
if ( this.entity_type === 'user' ) {
const User = this.models.get('auth:User')
const user = await User.findById(this.entity_id)
entity_display = `User: ${user.last_name}, ${user.first_name} (${user.uid})`
entity_display = `User: ${user.last_name}, ${user.first_name} (${user.uid.toLowerCase()})`
} else if ( this.entity_type === 'group' ) {
const Group = this.models.get('auth:Group')
const group = await Group.findById(this.entity_id)

View File

@@ -19,7 +19,7 @@ class ClientModel extends Model {
const user = new User({
first_name: name,
last_name: '(LDAP Agent)',
uid,
uid: uid.toLowerCase(),
roles: ['ldap_client'],
})
@@ -58,7 +58,7 @@ class ClientModel extends Model {
id: this.id,
name: this.name,
user_id: user.id,
uid: user.uid,
uid: user.uid.toLowerCase(),
last_invocation: this.last_invocation,
permissions: [...user.permissions, ...role_permissions],
}