sources/ldap(major): add sync_users and sync_groups, rewrite auth_user method
This commit is contained in:
17
passbook/sources/ldap/migrations/0002_auto_20191011_0825.py
Normal file
17
passbook/sources/ldap/migrations/0002_auto_20191011_0825.py
Normal file
@ -0,0 +1,17 @@
|
||||
# Generated by Django 2.2.6 on 2019-10-11 08:25
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('passbook_sources_ldap', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='ldappropertymapping',
|
||||
options={'verbose_name': 'LDAP Property Mapping', 'verbose_name_plural': 'LDAP Property Mappings'},
|
||||
),
|
||||
]
|
32
passbook/sources/ldap/migrations/0003_auto_20191011_0825.py
Normal file
32
passbook/sources/ldap/migrations/0003_auto_20191011_0825.py
Normal file
@ -0,0 +1,32 @@
|
||||
# Generated by Django 2.2.6 on 2019-10-11 08:25
|
||||
|
||||
from django.apps.registry import Apps
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def create_default_ad_property_mappings(apps: Apps, schema_editor):
|
||||
LDAPPropertyMapping = apps.get_model('passbook_sources_ldap', 'LDAPPropertyMapping')
|
||||
mapping = {
|
||||
'name': 'name',
|
||||
'givenName': 'first_name',
|
||||
'sn': 'last_name',
|
||||
'sAMAccountName': 'username',
|
||||
'mail': 'email'
|
||||
}
|
||||
for ldap_property, object_field in mapping.items():
|
||||
LDAPPropertyMapping.objects.get_or_create(
|
||||
ldap_property=ldap_property,
|
||||
object_field=object_field,
|
||||
defaults={
|
||||
'name': f"Autogenerated LDAP Mapping: {ldap_property} -> {object_field}"
|
||||
})
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('passbook_sources_ldap', '0002_auto_20191011_0825'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(create_default_ad_property_mappings)
|
||||
]
|
25
passbook/sources/ldap/migrations/0004_auto_20191011_0839.py
Normal file
25
passbook/sources/ldap/migrations/0004_auto_20191011_0839.py
Normal file
@ -0,0 +1,25 @@
|
||||
# Generated by Django 2.2.6 on 2019-10-11 08:39
|
||||
|
||||
import django.core.validators
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('passbook_sources_ldap', '0003_auto_20191011_0825'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='ldapsource',
|
||||
name='server_uri',
|
||||
field=models.TextField(validators=[django.core.validators.URLValidator(schemes=['ldap', 'ldaps'])]),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='ldapsource',
|
||||
name='sync_parent_group',
|
||||
field=models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.SET_DEFAULT, to='passbook_core.Group'),
|
||||
),
|
||||
]
|
Reference in New Issue
Block a user