LDAP - cast modifications to support posix logins
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone Build is passing

This commit is contained in:
Garrett Mills 2021-03-10 15:48:27 -06:00
parent a8729930e6
commit 20e723f39f
Signed by: garrettmills
GPG Key ID: D2BF5FBA8298F246
3 changed files with 24 additions and 2 deletions

View File

@ -38,9 +38,26 @@ class User extends AuthUser {
photo_file_id: String, photo_file_id: String,
trap: String, trap: String,
notify_config: NotifyConfig, notify_config: NotifyConfig,
uid_number: Number,
}} }}
} }
async get_uid_number() {
if ( !this.uid_number ) {
const Setting = this.models.get('Setting')
let last_uid = await Setting.get('ldap.last_alloc_uid')
if ( last_uid < 1 ) {
last_uid = this.configs.get('ldap:server.schema.start_uid')
}
this.uid_number = last_uid + 1
await Setting.set('ldap.last_alloc_uid', this.uid_number)
await this.save()
}
return this.uid_number
}
async photo() { async photo() {
const File = this.models.get('upload::File') const File = this.models.get('upload::File')
return File.findById(this.photo_file_id) return File.findById(this.photo_file_id)
@ -179,10 +196,13 @@ class User extends AuthUser {
sn: this.last_name, sn: this.last_name,
gecos: `${this.first_name} ${this.last_name}`, gecos: `${this.first_name} ${this.last_name}`,
mail: this.email, mail: this.email,
objectClass: ['inetOrgPerson', 'person'], objectClass: ['inetOrgPerson', 'person', 'posixaccount'],
objectclass: ['inetOrgPerson', 'person', 'posixaccount'],
entryuuid: this.uuid, entryuuid: this.uuid,
entryUUID: this.uuid, entryUUID: this.uuid,
objectGuid: this.uuid, objectGuid: this.uuid,
objectguid: this.uuid,
uidnumber: await this.get_uid_number(),
} }
if ( this.tagline ) ldap_data.extras_tagline = this.tagline if ( this.tagline ) ldap_data.extras_tagline = this.tagline

View File

@ -11,7 +11,8 @@ const ldap_server = {
group_base: env('LDAP_GROUP_BASE', 'ou=groups'), group_base: env('LDAP_GROUP_BASE', 'ou=groups'),
auth: { auth: {
user_id: 'uid', user_id: 'uid',
} },
start_uid: env('LDAP_START_UID', 80000),
}, },
format: { format: {

View File

@ -4,6 +4,7 @@ const setting_config = {
'auth.default_roles': [ 'base_user' ], 'auth.default_roles': [ 'base_user' ],
'home.allow_landing': true, 'home.allow_landing': true,
'home.redirect_authenticated': true, 'home.redirect_authenticated': true,
'ldap.last_alloc_uid': -1,
} }
} }