-
Notifications
You must be signed in to change notification settings - Fork 136
Allow AL internal UniqueID to be used as attribute #135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow AL internal UniqueID to be used as attribute #135
Conversation
If configured, map AL internal unique id as an attribute to be used by satosa, microservices and other plugins.
|
One line was missing from the commit of @jkakavas. As this is just a trivial oversight, I prefer not to open a merge request to his tree but paste the solution here. Feel free to apply it or wait for him to update this pull request. index ad4202e..b437129 100644
--- a/src/satosa/micro_services/account_linking.py
+++ b/src/satosa/micro_services/account_linking.py
@@ -32,6 +32,7 @@ class AccountLinking(ResponseMicroService):
self.redirect_url = config["redirect_url"]
self.signing_key = RSAKey(key=rsa_load(config["sign_key"]), use="sig", alg="RS256")
self.endpoint = "/handle_account_linking"
+ self.config = config
logger.info("Account linking is active")
def _handle_al_response(self, context):``` |
| satosa_logging(logger, logging.INFO, "issuer/id pair is linked in AL service", | ||
| context.state) | ||
| internal_response.user_id = message | ||
| id_to_attr = self.config.get("id_to_attr", None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
config is static and set at initialisation time through __init__. I propose we move this to __init__ too, as id_to_attr is not going to change and calling .get over and over is only wasting cpu cycles.
@@ -32,6 +32,7 @@ def __init__(self, config, *args, **kwargs):
self.redirect_url = config["redirect_url"]
self.signing_key = RSAKey(key=rsa_load(config["sign_key"]), use="sig", alg="RS256")
self.endpoint = "/handle_account_linking"
+ self.config = config
+ self.id_to_attr = self.config.get("id_to_attr", None)
logger.info("Account linking is active")
def _handle_al_response(self, context):then all you need to do is
if self.id_to_attr:
internal_response.attributes[self.id_to_attr] = [message]There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm only using self.config = config in order to get id_to_attr later on, so we even could do something like
self.id_to_attr = config.get("id_to_attr", None)
| internal_response.user_id = message | ||
| id_to_attr = self.config.get("id_to_attr", None) | ||
| if id_to_attr: | ||
| internal_response.attributes[id_to_attr] = message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which brings me to the next point, which is that attributes are stored as an array of attribute-values. I think this should be
internal_response.attributes[id_to_attr] = [message]
# ^ notice the bracketsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch, thanks
|
LGTM |
If configured, map AL internal unique id as an attribute to be used
by satosa, microservices and other plugins.