use pamela instead of simplepam

and open PAM sessions after successful auth
This commit is contained in:
Min RK
2015-09-08 14:45:11 +02:00
parent a1a10be747
commit 15e50529ff
2 changed files with 8 additions and 7 deletions

View File

@@ -8,7 +8,7 @@ import pwd
from subprocess import check_call, check_output, CalledProcessError from subprocess import check_call, check_output, CalledProcessError
from tornado import gen from tornado import gen
import simplepam import pamela
from traitlets.config import LoggingConfigurable from traitlets.config import LoggingConfigurable
from traitlets import Bool, Set, Unicode, Any from traitlets import Bool, Set, Unicode, Any
@@ -208,10 +208,11 @@ class PAMAuthenticator(LocalAuthenticator):
username = data['username'] username = data['username']
if not self.check_whitelist(username): if not self.check_whitelist(username):
return return
# simplepam wants bytes, not unicode try:
# see simplepam#3 pamela.authenticate(username, data['password'], service=self.service)
busername = username.encode(self.encoding) pamela.open_session(username, service=self.service)
bpassword = data['password'].encode(self.encoding) except pamela.PAMError as e:
if simplepam.authenticate(busername, bpassword, service=self.service): self.log.warn("PAM Authentication failed: %s", e)
else:
return username return username

View File

@@ -1,6 +1,6 @@
traitlets>=4 traitlets>=4
tornado>=4 tornado>=4
jinja2 jinja2
simplepam pamela
sqlalchemy sqlalchemy
requests requests