An authentication policy for Pyramid that proxies to a stack of other authentication policies.
Overview
MultiAuthenticationPolicy is a Pyramid authentication policy that proxies to a stack of other IAuthenticationPolicy objects, to provide a combined auth solution from individual pieces. Simply pass it a list of policies that should be tried in order:
policies = [
IPAuthenticationPolicy("127.0.*.*", principals=["local"])
IPAuthenticationPolicy("192.168.*.*", principals=["trusted"])
]
authn_policy = MultiAuthenticationPolicy(policies)
config.set_authentication_policy(authn_policy)
This example uses the pyramid_ipauth module to assign effective principals based on originating IP address of the request. It combines two such policies so that requests originating from “127.0.*.*” will have principal “local” while requests originating from “192.168.*.*” will have principal “trusted”.
In general, the results from the stacked authentication policies are combined as follows:
authenticated_userid: return userid from first successful policy
unauthenticated_userid: return userid from first successful policy
effective_principals: return union of principals from all policies
remember: return headers from all policies
forget: return headers from all policies
Deployment Settings
It is also possible to specify the authentication policies as part of your paste deployment settings. Consider the following example:
[app:pyramidapp] use = egg:mypyramidapp multiauth.policies = ipauth1 ipauth2 pyramid_browserid multiauth.policy.ipauth1.use = pyramid_ipauth.IPAuthentictionPolicy multiauth.policy.ipauth1.ipaddrs = 127.0.*.* multiauth.policy.ipauth1.principals = local multiauth.policy.ipauth2.use = pyramid_ipauth.IPAuthentictionPolicy multiauth.policy.ipauth2.ipaddrs = 192.168.*.* multiauth.policy.ipauth2.principals = trusted
To configure authentication from these settings, simply include the multiauth module into your configurator:
config.include("pyramid_multiauth")
In this example you would get a MultiAuthenticationPolicy with three stacked auth policies. The first two, ipauth1 and ipauth2, are defined as the name of of a callable along with a set of keyword arguments. The third is defined as the name of a module, pyramid_browserid, which will be processed via the standard config.include() mechanism.
The end result would be a system that authenticates users via BrowserID, and assigns additional principal identifiers based on the originating IP address of the request.
If necessary, the group finder function and the authorization policy can also be specified from configuration:
[app:pyramidapp] use = egg:mypyramidapp multiauth.authorization_policy = mypyramidapp.acl.Custom multiauth.groupfinder = mypyramidapp.acl.groupfinder ...
MultiAuthPolicySelected Event
An event is triggered when one of the multiple policies configured is selected.
from pyramid_multiauth import MultiAuthPolicySelected
# Track policy used, for prefixing user_id and for logging.
def on_policy_selected(event):
print("%s (%s) authenticated %s for request %s" % (event.policy_name,
event.policy,
event.userid,
event.request))
config.add_subscriber(on_policy_selected, MultiAuthPolicySelected)
Metadata
Release files for pyramid-multiauth 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pyramid_multiauth-1.1.0.tar.gz | 34.3 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyramid_multiauth-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 54.2 kB
Release files / pyramid_multiauth-1.1.0.tar.gz
| Download URL | pyramid_multiauth-1.1.0.tar.gz |
|---|---|
| Size | 34.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aba7d9697b5888c5958d22bdd01e05d254b8707d222027afe95c16078759ea69
|
|
BLAKE2b-256 checksum How to use checksums |
b74417b576b4b01237f6bc4161f0c5aeff07a5eae6f0e0205c8d47296e4f1092
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 18, 2026.
Transparency logRelease files / pyramid_multiauth-1.1.0-py3-none-any.whl
| Download URL | pyramid_multiauth-1.1.0-py3-none-any.whl |
|---|---|
| Size | 19.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
341ceed277c1d80aa0e62a4d0ef31dfd0bf33c75b5dd020856d0c4d8d1e3f77e
|
|
BLAKE2b-256 checksum How to use checksums |
0ee74b15c454ec192d8212f88b4e8cef28a444909b9519382de37a7f28af88c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 18, 2026.
Transparency logSecurity for pyramid-multiauth 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for pyramid_multiauth-1.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 18, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.