summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTheron Luhn <theron@luhn.com>2019-04-15 19:14:42 -0700
committerTheron Luhn <theron@luhn.com>2019-04-15 19:14:42 -0700
commitd6e543bc01d2f1aa3bb29f005171911f6f09da02 (patch)
tree06bb8c9ac7089de2a20287ef703229b22ce777d1 /src
parentf4c6c993ded900b4e32d1dd49207ca1e18b11336 (diff)
downloadpyramid-d6e543bc01d2f1aa3bb29f005171911f6f09da02.tar.gz
pyramid-d6e543bc01d2f1aa3bb29f005171911f6f09da02.tar.bz2
pyramid-d6e543bc01d2f1aa3bb29f005171911f6f09da02.zip
Move SessionAuthenticationHelper to pyramid.authentication.
Diffstat (limited to 'src')
-rw-r--r--src/pyramid/authentication.py31
-rw-r--r--src/pyramid/security.py31
2 files changed, 31 insertions, 31 deletions
diff --git a/src/pyramid/authentication.py b/src/pyramid/authentication.py
index 21cfc0c0e..4f8077309 100644
--- a/src/pyramid/authentication.py
+++ b/src/pyramid/authentication.py
@@ -1118,6 +1118,37 @@ class SessionAuthenticationPolicy(CallbackAuthenticationPolicy):
return request.session.get(self.userid_key)
+class SessionAuthenticationHelper:
+ """ A helper for use with a :term:`security policy` which stores user data
+ in the configured :term:`session`.
+
+ Constructor Arguments
+
+ ``prefix``
+
+ A prefix used when storing the authentication parameters in the
+ session. Defaults to 'auth.'. Optional.
+
+ """
+
+ def __init__(self, prefix='auth.'):
+ self.userid_key = prefix + 'userid'
+
+ def remember(self, request, userid, **kw):
+ """ Store a userid in the session."""
+ request.session[self.userid_key] = userid
+ return []
+
+ def forget(self, request):
+ """ Remove the stored userid from the session."""
+ if self.userid_key in request.session:
+ del request.session[self.userid_key]
+ return []
+
+ def identify(self, request):
+ return request.session.get(self.userid_key)
+
+
@implementer(IAuthenticationPolicy)
class BasicAuthAuthenticationPolicy(CallbackAuthenticationPolicy):
""" A :app:`Pyramid` authentication policy which uses HTTP standard basic
diff --git a/src/pyramid/security.py b/src/pyramid/security.py
index dda61ef27..5d157d219 100644
--- a/src/pyramid/security.py
+++ b/src/pyramid/security.py
@@ -540,34 +540,3 @@ class ACLHelper:
allowed.update(allowed_here)
return allowed
-
-
-class SessionAuthenticationHelper:
- """ A helper for use with a :term:`security policy` which stores user data
- in the configured :term:`session`.
-
- Constructor Arguments
-
- ``prefix``
-
- A prefix used when storing the authentication parameters in the
- session. Defaults to 'auth.'. Optional.
-
- """
-
- def __init__(self, prefix='auth.'):
- self.userid_key = prefix + 'userid'
-
- def remember(self, request, userid, **kw):
- """ Store a userid in the session."""
- request.session[self.userid_key] = userid
- return []
-
- def forget(self, request):
- """ Remove the stored userid from the session."""
- if self.userid_key in request.session:
- del request.session[self.userid_key]
- return []
-
- def identify(self, request):
- return request.session.get(self.userid_key)