Skip to content

Commit fd50aa3

Browse files
committed
Add KEY_METADATA_STORE to store the saml2 metadata store
KEY_METADATA_STORE will hold the metadata store for saml2 backends and frontends. Accessing it that through the Context object will allow one to peek into the metadata of the corresponding backend or frontend. Previously, KEY_BACKEND_METADATA_STORE was used for this reason, but was available only on the backend. It is now a deprecated alias. Signed-off-by: Ivan Kanakarakis <[email protected]>
1 parent e48d9bb commit fd50aa3

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

src/satosa/backends/saml2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ def authn_response(self, context, binding):
343343
logger.debug(logline)
344344
raise SATOSAAuthenticationError(context.state, "State did not match relay state")
345345

346-
context.decorate(Context.KEY_BACKEND_METADATA_STORE, self.sp.metadata)
346+
context.decorate(Context.KEY_METADATA_STORE, self.sp.metadata)
347347
if self.config.get(SAMLBackend.KEY_MEMORIZE_IDP):
348348
issuer = authn_response.response.issuer.text.strip()
349349
context.state[Context.KEY_MEMORIZED_IDP] = issuer

src/satosa/context.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from warnings import warn as _warn
2+
13
from satosa.exception import SATOSAError
24

35

@@ -12,7 +14,7 @@ class Context(object):
1214
"""
1315
Holds methods for sharing proxy data through the current request
1416
"""
15-
KEY_BACKEND_METADATA_STORE = 'metadata_store'
17+
KEY_METADATA_STORE = 'metadata_store'
1618
KEY_TARGET_ENTITYID = 'target_entity_id'
1719
KEY_FORCE_AUTHN = 'force_authn'
1820
KEY_MEMORIZED_IDP = 'memorized_idp'
@@ -28,9 +30,13 @@ def __init__(self):
2830
self.cookie = None
2931
self.state = None
3032

31-
def __repr__(self):
32-
from pprint import pformat
33-
return pformat(vars(self))
33+
@property
34+
def KEY_BACKEND_METADATA_STORE(self):
35+
msg = "'{old_key}' is deprecated; use '{new_key}' instead.".format(
36+
old_key="KEY_BACKEND_METADATA_STORE", new_key="KEY_METADATA_STORE"
37+
)
38+
_warn(msg, DeprecationWarning)
39+
return Context.KEY_METADATA_STORE
3440

3541
@property
3642
def path(self):

src/satosa/frontends/saml2.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ def _handle_authn_request(self, context, binding_in, idp):
247247
idp, idp_policy, requester, context.state
248248
)
249249

250+
context.decorate(Context.KEY_METADATA_STORE, self.idp.metadata)
250251
return self.auth_req_callback_func(context, internal_req)
251252

252253
def _get_approved_attributes(self, idp, idp_policy, sp_entity_id, state):

0 commit comments

Comments
 (0)