File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change 1+ import os
2+
3+ import yaml
4+
5+ from satosa .internal_data import DataConverter
6+ from satosa .micro_service .service_base import ResponseMicroService
7+
8+
9+ class AddStaticAttributes (ResponseMicroService ):
10+ """
11+ Add static attributes to the responses.
12+
13+ The path to the file describing the mapping (as YAML) of static attributes must be specified
14+ with the environment variable 'SATOSA_STATIC_ATTRIBUTES'.
15+ """
16+ def __init__ (self , internal_attributes ):
17+ super (AddStaticAttributes , self ).__init__ ()
18+ self .data_converter = DataConverter (internal_attributes )
19+
20+ mapping_file = os .environ .get ("SATOSA_STATIC_ATTRIBUTES" )
21+ if not mapping_file :
22+ raise ValueError ("Could not find file containing mapping of static attributes." )
23+
24+ with open (mapping_file ) as f :
25+ self .static_attributes = yaml .safe_load (f )
26+
27+ def process (self , context , data ):
28+ all_attributes = data .get_attributes ()
29+ all_attributes .update (self .data_converter .to_internal ("saml" , self .static_attributes ))
30+ data .add_attributes (all_attributes )
31+ return data
You can’t perform that action at this time.
0 commit comments