sapl-pymongo
SAPL signal source for PyMongo. Contributes the MONGO_QUERY signal and a
mongo:queryRewriting constraint handler provider so a SAPL policy can shape
the MongoDB queries an application issues, the same way sapl-sqlalchemy
contributes SQL_QUERY for relational queries.
PyMongo's driver-monitoring API is observe-only, so there is no central mutating
query hook. The cut point is therefore a thin proxy over the collection's
query-issuing methods (find, find_one, aggregate, count_documents,
update_*, delete_*). Each wrapped call discharges MONGO_QUERY with the
structured query (a filter mapping or an aggregation pipeline) before delegating
to the driver. A synchronous proxy backs the blocking enforcement path (Flask,
sync Django); an asynchronous proxy backs the async path (FastAPI, Tornado,
async Django).
Obligation
MongoDbQueryRewritingProvider handles the mongo:queryRewriting obligation,
mirroring the Spring provider so the same obligation narrows identically on every SAPL
Mongo PEP. Two shapes, combinable, narrowing-only (criteria and conditions are AND-merged
into the user's filter, never widening it):
{
"type": "mongo:queryRewriting",
"criteria": [
{"column": "tenantId", "op": "=", "value": 7},
{"or": [{"column": "ownerId", "op": "=", "value": "alice"},
{"column": "public", "op": "=", "value": true}]}
],
"conditions": ["{\"age\": {\"$gte\": 18}}"]
}
criteria ops: =, !=, >, >=, <, <=, in, isNull, isNotNull; and / or
group nested criteria. conditions carries raw filter fragments for operators the typed
form cannot express ($regex, $exists, $geoWithin); for cross-PEP portability the
strings must be double-quoted (extended) JSON. An aggregation pipeline cannot be expressed
by this contract, so a pipeline intercept fails closed, as does a malformed condition.
Usage
from sapl_pymongo import MongoDbQueryRewritingProvider, wrap_collection
# At startup: wrap each collection once (this also registers the shim with the planner).
widgets = wrap_collection(database["widgets"])
# Register the provider with the EnforcementPlanner that backs your framework wrapper.
# providers=(MongoDbQueryRewritingProvider(),)
# In a @pre_enforce-protected handler, query the wrapped collection as usual; a
# mongo:queryRewriting obligation on the decision narrows the filter automatically.
Metadata
Release files for sapl-pymongo 4.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 | Actions |
|---|---|---|---|---|
| sapl_pymongo-4.1.0.tar.gz | 13.8 kB | Without provenance | Details for sapl_pymongo-4.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sapl_pymongo-4.1.0-py3-none-any.whl | Python 3 | none | any | Details for sapl_pymongo-4.1.0-py3-none-any.whl |
Total release size: 22.0 kB
Release files / sapl_pymongo-4.1.0.tar.gz
| Download URL | sapl_pymongo-4.1.0.tar.gz |
|---|---|
| Size | 13.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
40bed79c99f2577456b43752db1e3a4284a2a532e5d959b4a1ac79743f61f006
|
|
BLAKE2b-256 checksum How to use checksums |
9751c510e871641a8ce0f4b006f6a841e38d1e5fe663bcab7f7d0e401efba18d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Release files / sapl_pymongo-4.1.0-py3-none-any.whl
| Download URL | sapl_pymongo-4.1.0-py3-none-any.whl |
|---|---|
| Size | 8.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a443d76bc128107d9e1eb9c3cb5d18739ab315361b7221bbdad5d5612fdda63d
|
|
BLAKE2b-256 checksum How to use checksums |
55e67d5984107b797be44371b64b6e09c5f048ec9724fdae48fce89397247dae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Security for sapl-pymongo 4.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.