forked from mtusi2026/mtusi2026lab7
feat(security): add scoped identities, TLS boundaries and OpenBao bootstrap
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
"""Reload trust and the current client leaf for every network connection."""
|
||||
|
||||
import urllib3
|
||||
from urllib3.connection import HTTPSConnection
|
||||
from urllib3.connectionpool import HTTPSConnectionPool
|
||||
|
||||
from src import identity
|
||||
|
||||
|
||||
class CurrentConnection(HTTPSConnection):
|
||||
def connect(self):
|
||||
self.ssl_context = identity.tls_context()
|
||||
self.cert_reqs = "CERT_REQUIRED"
|
||||
return super().connect()
|
||||
|
||||
|
||||
class CurrentPool(HTTPSConnectionPool):
|
||||
ConnectionCls = CurrentConnection
|
||||
|
||||
|
||||
def pool(**kwargs):
|
||||
manager = urllib3.PoolManager(**kwargs)
|
||||
# Copy before changing: PoolManager otherwise shares the class mapping.
|
||||
manager.pool_classes_by_scheme = dict(manager.pool_classes_by_scheme)
|
||||
manager.pool_classes_by_scheme["https"] = CurrentPool
|
||||
return manager
|
||||
Reference in New Issue
Block a user