Skip to content

Commit

Permalink
Merge pull request #132 from jkakavas/add_scope_remover
Browse files Browse the repository at this point in the history
Add scope remover processor
  • Loading branch information
johanlundberg authored Sep 7, 2017
2 parents 9f39965 + ebca2e4 commit fe7a267
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/satosa/micro_services/processors/scope_remover_processor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from ..attribute_processor import AttributeProcessorError, AttributeProcessorWarning
from .base_processor import BaseProcessor

class ScopeRemoverProcessor(BaseProcessor):
"""
Removes the scope from all values of a given attribute
"""
def process(self, internal_data, attribute, **kwargs):
attributes = internal_data.attributes
new_values = []
values = attributes.get(attribute, [])
if not values:
raise AttributeProcessorWarning("Attribute {} has no values".format(attribute))
for value in values:
unscoped_value = value.split('@')[0]
new_values.append(unscoped_value)
attributes[attribute] = new_values

0 comments on commit fe7a267

Please sign in to comment.