cnobile2012 / django-pam Goto Github PK
View Code? Open in Web Editor NEWA Django PAM Authentication Backend implementation.
License: MIT License
A Django PAM Authentication Backend implementation.
License: MIT License
Please update the documentation with a complete example for these Login and Logout views. I tried to follow the "example_site" but no luck.
I'm trying to use the LoginView() and LogoutView() but I cannot make to work the LogoutView.
It logs me out successfully when I click LogOut but if I try to access a direct link afterwards it does go to it without asking for login (somehow it bypasses authentication).
I'm using the @method_decorator(login_required() and if I clear the browser cache and logout it works and forces me the login before accessing the desired page.
Also I have and issue with the Logout redirect. After logout I'm trying to redirect to the login page and it does but the URL still display the logout link.
I'm using python 3.7.2 on Debian.
On trying to authenticate with a system user, I get the following error -
[07/Jun/2016 17:33:49] "GET /admin/login/?next=/admin/ HTTP/1.1" 200 1724
Unhandled exception in thread started by <function wrapper at 0x1f10410>
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 226, in wrapper
fn(_args, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 144, in inner_run
ipv6=self.use_ipv6, threading=threading)
File "/usr/local/lib/python2.7/dist-packages/django/core/servers/basehttp.py", line 193, in run
httpd.serve_forever()
File "/usr/lib/python2.7/SocketServer.py", line 225, in serve_forever
r, w, e = select.select([self], [], [], poll_interval)
select.error: (4, 'Interrupted system call')
If I stop the server and start it again, and revisit the admin url, it automatically logs me in.
Please let me know what further information you need to advise.
Hi,
I was running a compatibility check with Django 3.0 and the module is not functioning due the change:
Would it possible to change "six" instead of the django.utils.six ?
django-pam doesn't work on Django 4 because ugettext,ugettext_lazy,and force_text no longer exist.
The following imports:
from django.utils.translation import ugettext, ugettext_lazy as _
from django.utils.encoding import force_text
need to be replaced with:
from django.utils.translation import gettext, gettext_lazy as _
from django.utils.encoding import force_str
Hey @cnobile2012 ! I just added this module to Singularity Registry Server, and I'm having trouble testing it out. Would it be possible to get an example of how to create a user (in a Docker container) and then log in? I haven't used pam so I'm only familiar with useradd
. Thank you!
This is a suggestion for changin description
in setup.py
to a shorter text like Django PAM authentication backend implementation. And, long_description
for the text that currently has description
plus a reference to README.rst
.
Why? Because it helps tools like pytoport to comply with porting guidelines. And surely other packaging frameworks will thank the change.
I'm packaging django-pam for FreeBSD and I got the advise to request this change. See this PR for better reference.
See: https://docs.djangoproject.com/en/3.1/releases/3.1/#id2
request.is_ajax()
should be replaced with:
request.headers.get('x-requested-with') == 'XMLHttpRequest'
The assert
in
django-pam/django_pam/auth/backends.py
Line 52 in 0d854b9
/api-token-auth
page (see https://www.django-rest-framework.org/api-guide/authentication/).
request
is then a rest_framework.request.Request
.
If the assert is commented out, it works as expected.
IMHO the assert not required in the code, as request
isn't used in that method at all. So a condition on it to be from a fixed type is not necessary.
When using this package together with Django 3.1 and having a custom user model with the id defined like this:
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
An error comes just after login, where it complains about the missing isdigit
attribute
Traceback (most recent call last):
File "/srv/wpaas/lib/python3.6/site-packages/asgiref/sync.py", line 339, in thread_handler
raise exc_info[1]
File "/srv/wpaas/lib/python3.6/site-packages/django/core/handlers/exception.py", line 38, in inner
response = await get_response(request)
File "/srv/wpaas/lib/python3.6/site-packages/django/core/handlers/base.py", line 231, in _get_response_async
response = await wrapped_callback(request, *callback_args, **callback_kwargs)
File "/srv/wpaas/lib/python3.6/site-packages/asgiref/sync.py", line 304, in __call__
ret = await asyncio.wait_for(future, timeout=None)
File "/usr/lib/python3.6/asyncio/tasks.py", line 339, in wait_for
return (yield from fut)
File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "/srv/wpaas/lib/python3.6/site-packages/asgiref/sync.py", line 343, in thread_handler
return func(*args, **kwargs)
File "/srv/wpaas/lib/python3.6/site-packages/django/views/generic/base.py", line 70, in view
return self.dispatch(request, *args, **kwargs)
File "/srv/wpaas/lib/python3.6/site-packages/django/contrib/auth/mixins.py", line 50, in dispatch
if not request.user.is_authenticated:
File "/srv/wpaas/lib/python3.6/site-packages/django/utils/functional.py", line 240, in inner
self._setup()
File "/srv/wpaas/lib/python3.6/site-packages/django/utils/functional.py", line 376, in _setup
self._wrapped = self._setupfunc()
File "/srv/wpaas/lib/python3.6/site-packages/django/contrib/auth/middleware.py", line 23, in <lambda>
request.user = SimpleLazyObject(lambda: get_user(request))
File "/srv/wpaas/lib/python3.6/site-packages/django/contrib/auth/middleware.py", line 11, in get_user
request._cached_user = auth.get_user(request)
File "/srv/wpaas/lib/python3.6/site-packages/django/contrib/auth/__init__.py", line 181, in get_user
user = backend.get_user(user_id)
File "/srv/wpaas/lib/python3.6/site-packages/django_pam/auth/backends.py", line 85, in get_user
or user_data.isdigit()):
AttributeError: 'UUID' object has no attribute 'isdigit'
The application which we use django-pam, has a dependency on an external system, which requires the ID of users to be named id
in the database and also to be of type uuid
.
Is there some way in the library to get it to work with UUID or would there need to be a fix to handle this?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.