Registry / web-framework / repoze.who

repoze.who

JSON →
library3.1.0pypypiunverified

repoze.who is an identification and authentication framework for WSGI applications. It provides middleware to manage user identification, authentication, and authorization. The current stable version is 3.1.0, and it is actively maintained by the Pylons Project, though releases are infrequent.

pip install repoze.who
INSTALL
IMPORT
SIG · REPOZE.WHO
R
repoze.who
web-frameworkpythonv3.1.0
Install
2.3s avg
Import
—
Disk
24MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v3.1.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 22MB
glibc
py 3.10–3.910 runs
installs and imports cleanly · install 2.3s · import 0.000s · 23MB
24MB installed
● package 24MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

make_who_with_config
✓ from repoze.who.config import make_middleware_with_config
✗ from repoze.who.config import make_who_with_config

This quickstart demonstrates setting up `repoze.who` with a basic authenticator and `BasicAuthPlugin` for identification and challenging. It shows how to use `make_who_with_config` to create the middleware and `add_new_r_w_to_environ` to populate the WSGI environment, then access the identity from `request.environ`. To run this example, you will also need to install `webob` and a WSGI server like `waitress`.

import os from webob.dec import wsgify from webob import Response from repoze.who.config import make_who_with_config, add_new_r_w_to_environ from repoze.who.plugins.basicauth import BasicAuthPlugin # Example plugin # Dummy WSGI application @wsgify def my_app(request): identity = request.environ.get('repoze.who.identity') if identity: username = identity.get('repoze.who.userid') return Response(f'Hello, {username}! You are authenticated.') else: return Response('Please authenticate.', status=401) # Configure repoze.who # For real applications, use proper credential storage users_db = {'admin': 'secret', 'user': 'password'} def my_authenticator(environ, identity): if 'login' in identity and 'password' in identity: login = identity['login'] password = identity['password'] if users_db.get(login) == password: identity['repoze.who.userid'] = login # Store userid return login return None # Example challenge (basic auth) basic_auth_plugin = BasicAuthPlugin('My Realm') # Who config dictionary (simplified) who_config = { 'identifiers': [('basic_auth_identifier', basic_auth_plugin)], 'authenticators': [('my_auth', my_authenticator)], 'challengers': [('basic_auth_challenger', basic_auth_plugin)], 'log_stream': None, 'log_level': 10 # DEBUG } # Create WhoMiddleware who_middleware_app = make_who_with_config(my_app, who_config) # Wrap the app to ensure 'repoze.who' object is in environ @wsgify def wrapped_app(request): add_new_r_w_to_environ(request.environ, who_config) return who_middleware_app(request) # To run this with a WSGI server (e.g., waitress): # pip install webob waitress # from waitress import serve # serve(wrapped_app, host='0.0.0.0', port=8000) # (Uncomment above lines to run)
Debug
Known issues
breakingrepoze.who 3.x (and higher) is Python 3.9+ only. Earlier versions (2.x) supported Python 2.x. Porting from 2.x requires adapting to Python 3 syntax and potentially updated configuration approaches.
fix
Upgrade your environment to Python 3.9+ and ensure all dependencies are Python 3 compatible. Review the 3.x documentation for configuration changes, especially the use of `make_who_with_config`.
affects: <3.0
breakingThe primary method for instantiating the WhoMiddleware has changed. Direct import of `WhoMiddleware` from `repoze.who.middleware` (common in 2.x) is not the recommended approach in 3.x; instead, use `make_who_with_config`.
fix
Replace direct `WhoMiddleware` imports and instantiation with `from repoze.who.config import make_who_with_config` and use the configuration dictionary.
affects: 2.x -> 3.x
gotchaForgetting to call `add_new_r_w_to_environ` after creating the `repoze.who` middleware means that the `repoze.who` object (containing identifiers, authenticators, etc.) will not be available in the WSGI environment for subsequent requests, leading to unexpected behavior or errors.
fix
Ensure `from repoze.who.config import add_new_r_w_to_environ` is imported and called, typically within your WSGI application's request processing or wrapped around the main `WhoMiddleware`.
affects: 3.x
gotchaConfiguration of `repoze.who` relies on a dictionary structure passed to `make_who_with_config`. Incorrectly formatted dictionaries (e.g., missing required keys, invalid plugin instances) will lead to runtime errors that can be hard to diagnose.
fix
Carefully review the `who_config` dictionary structure. Ensure all identifiers, authenticators, and challengers are correctly instantiated and provided as `(name, plugin_instance)` tuples in their respective lists. Use `log_level=10` (DEBUG) for more verbose error messages during development.
affects: 3.x
Upgrade
Version history
3.1.0latest on PyPI · released Feb 22, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
6
OpenAI (training)
1
Resources
repoze.who — pip install repoze.who · libregistry