PySAML2 supports Entity Categories in two distinct ways depending on whether you want to include them in your metadata or use them to filter attributes released to Service Providers (SPs).
1. Including Entity Categories in Metadata
To generate EntityAttribute metadata elements, use the entity_category_support configuration option. This is useful for declaring which categories your entity belongs to (e.g., edugain.COCO).
2. Using Entity Categories as Attribute Filters
To use Entity Categories as a filter that controls which attributes are released to an SP, include the entity_categories option within your policy configuration. If an SP does not conform to the specified categories, the attributes will not be released.
Note: Entity category definitions and attributes are located in src/saml2/entity_category/<registrar-of-entity-category>.py.
# Example 1: Metadata configuration
config = {
'entity_category_support': [
edugain.COCO, # "http://www.geant.net/uri/dataprotection-code-of-conduct/v1"
refeds.RESEARCH_AND_SCHOLARSHIP,
],
# ... other config
}
# Example 2: Policy configuration (Attribute Filtering)
config = {
"policy": {
"default": {
"lifetime": {"minutes": 15},
"entity_categories": ["refeds"],
}
}
}