Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Document using the pyramid authentication policy.

  • Loading branch information...
commit 1dc92e80c971897d546297863cd5b63426972881 1 parent 2df609a
@tseaver tseaver authored
Showing with 47 additions and 2 deletions.
  1. +2 −2 TODO.txt
  2. +1 −0  docs/index.rst
  3. +44 −0 docs/without_repoze_who.rst
View
4 TODO.txt
@@ -133,7 +133,7 @@ Password Reset
``pyramid`` Authentication Policy
---------------------------------
-- [/] Implement interface for use within ``pyramid`` sans ``repoze.who`` m/w.
+- [X] Implement interface for use within ``pyramid`` sans ``repoze.who`` m/w.
* N.B.: unlike the policy in ``pyramid_who``, do *not* use a
callback: instead, use the ``IRegistrations`` adapter to confirm user
@@ -141,7 +141,7 @@ Password Reset
* Add the ZCML directive to configure this policy.
- o Document using the policy.
+ * Document using the policy.
- [_] Extend ``effective_principals`` to include groups defined in admin UI.
View
1  docs/index.rst
@@ -11,6 +11,7 @@ Contents:
:maxdepth: 2
configuration
+ without_repoze_who
api
Indices and tables
View
44 docs/without_repoze_who.rst
@@ -0,0 +1,44 @@
+Using :mod:`cartouche` in :mod:`pyramid` without :mod:`repoze.who`
+==================================================================
+
+If you are not using :mod:`repoze.who` in your :mod:`pyramid` application,
+you can still use the :mod:`cartouche` authentication machinery
+by registering a custom "authentication policy". The policy object
+implements the ``pyramid.interfaces.IAuthenticationPolicy`` interface,
+allowing :mod:`pyramid` to authenticate users, as well as remembering /
+forgetting user credentials.
+
+The policy object uses two pieces of configuration data:
+
+``config_file``
+ The path to a :mod:``repoze.who``-style INI file, configuring
+ the plugins which implement the :mod:``repoze.who`` API.
+
+``identifier_name``
+ A string nameing the "identifier" plugin used when "remembering"
+ user credentials.
+
+
+To register this polcy via imperative Python code with the :mod:`pyramid`
+configurator:
+
+.. code-block:: python
+
+ from cartouche.pyramidpolicy import PyramidPolicy
+
+ policy = PyramidPolicy('/path/to/config_file', 'identifier')
+ configurator._set_authentication_policy(policy)
+
+To register the policy via ZCML, you need to include the ``meta.zcml``
+file which defines the
+
+.. code-block:: xml
+
+ <configure xmlns="http://pylonshq.com/pyramid">
+ <include package="cartouche" file="meta.zcml" />
+
+ <cartoucheauthenticationpolicy
+ config_file="/path/to/config_file"
+ identifier_name="identifier" />
+
+ </configure>
Please sign in to comment.
Something went wrong with that request. Please try again.