Skip to content

Commit cbb6d4a

Browse files
Merge pull request #135 from jkakavas/enhance_alservice
Allow AL internal UniqueID to be used as attribute
2 parents f167c65 + 94a0d8e commit cbb6d4a

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

example/plugins/microservices/account_linking.yaml.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ name: AccountLinking
33
config:
44
api_url: "https://localhost:8167"
55
redirect_url: "https://localhost:8167/approve"
6-
sign_key: "pki/account_linking.key"
6+
sign_key: "pki/account_linking.key"
7+
id_to_attr: "uniqueid"

src/satosa/micro_services/account_linking.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def __init__(self, config, *args, **kwargs):
3232
self.redirect_url = config["redirect_url"]
3333
self.signing_key = RSAKey(key=rsa_load(config["sign_key"]), use="sig", alg="RS256")
3434
self.endpoint = "/handle_account_linking"
35+
self.id_to_attr = config.get("id_to_attr", None)
3536
logger.info("Account linking is active")
3637

3738
def _handle_al_response(self, context):
@@ -52,6 +53,9 @@ def _handle_al_response(self, context):
5253
satosa_logging(logger, logging.INFO, "issuer/id pair is linked in AL service",
5354
context.state)
5455
internal_response.user_id = message
56+
if self.id_to_attr:
57+
internal_response.attributes[id_to_attr] = [message]
58+
5559
del context.state[self.name]
5660
return super().process(context, internal_response)
5761
else:
@@ -76,6 +80,8 @@ def process(self, context, internal_response):
7680
satosa_logging(logger, logging.INFO, "issuer/id pair is linked in AL service",
7781
context.state)
7882
internal_response.user_id = message
83+
if self.id_to_attr:
84+
internal_response.attributes[id_to_attr] = [message]
7985
try:
8086
del context.state[self.name]
8187
except KeyError:

0 commit comments

Comments
 (0)