No project description provided
Project description
Django-adtools is a package with a set of utilities for integrating web applications based on the django framework with MS ActiveDirectory.
All documentation is in the “docs/build” directory and online at http://django-adtools.readthedocs.org
Short example of using Active Directory authentication system
# views.py from django_adtools.ad.ad_tools import ad_login, ad_clear_username def post(self, request): form = LoginForm(request.POST) if form.is_valid(): if ad_login( # checking, if user is able to login using Active Directory credentials dc=DomainController.get(), # A hostname or an ip address of a Domain Controller username=form.cleaned_data['username'], password=form.cleaned_data['password'], domain=settings.ADTOOLS_DOMAIN, # A name of domain, e.g. domain.com group=settings.ADTOOLS_GROUP, # A group name of valid users ): # get full domain username like user@domain.ru username_without_domain = ad_clear_username(form.cleaned_data['username']) username = f"{username_without_domain}@{settings.ADTOOLS_DOMAIN}" try: # looking for existing user profile (case insensitive) user = User.objects.get(username__iexact=username) except User.DoesNotExist: # create a new user profile, if it does not exist user = User(username=username) user.save() login(request=request, user=user) return redirect(reverse(f'{__package__}:index')) context = {'package': __package__, 'form': form, 'login_failed': True, } return render(request, f"{__package__}/login.html", context)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
django-adtools-1.7.tar.gz
(10.9 kB
view details)
File details
Details for the file django-adtools-1.7.tar.gz.
File metadata
- Download URL: django-adtools-1.7.tar.gz
- Upload date:
- Size: 10.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c0100740c8fb1d93ab138338739314fd03c70f49f2a1fb3bc8b5bf01152fe07
|
|
| MD5 |
f5090a6f4cd110142d455331e69559f0
|
|
| BLAKE2b-256 |
6723347bc1b3c333320cd76797803dcaefeaae182b34da5fe1faf8990e8cf54c
|