Skip to content

Add SAMLResponseID and AuthnContextClassRef to response alterations - #92

Open
Fulvio Mercoliano (fume) wants to merge 2 commits into
mainfrom
feat/add-response-id-and-spidl-to-samlresponse-claims
Open

Add SAMLResponseID and AuthnContextClassRef to response alterations#92
Fulvio Mercoliano (fume) wants to merge 2 commits into
mainfrom
feat/add-response-id-and-spidl-to-samlresponse-claims

Conversation

@fume

Copy link
Copy Markdown
Collaborator

This pull request extends the optional SAML response alteration functionality to allow adding new attributes to the SAML response based on configuration. In addition to the existing date of birth alteration, it introduces options to add the SAML Response ID and AuthnContextClassRef as SAML attributes. The implementation ensures these attributes are only added when configured and logs the operations accordingly.

New optional SAML attribute injection features:

  • Added options to OptionalResponseAlterationOptions for injecting the SAML Response ID and AuthnContextClassRef as SAML attributes, including configuration for their names and types.
  • Updated ApplyOptionalResponseAlteration in FederatorResponseService to conditionally apply the new attribute injections using dedicated helper methods.
  • Implemented ApplySAMLResponseIDAttributeAlteration and ApplyAuthnContextClassRefAttributeAlteration methods to extract the relevant values from the SAML response and add them as attributes, using a template-based approach for consistency.

Logging enhancements:

  • Added new logging event constants for the addition of SAMLResponseID and AuthnContextClassRef attributes to LoggingEvents.
  • Logging added to the new attribute injection methods to track when attributes are added or when prerequisites are missing.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request extends the Proxy’s optional SAML response alteration feature set, enabling conditional injection of the SAML Response ID and the AuthnContextClassRef value into the assertion as new SAML attributes, driven by configuration and accompanied by new logging event IDs.

Changes:

  • Extended OptionalResponseAlterationOptions with flags and configuration (attribute names + xsi:type) for the two new injected attributes.
  • Updated FederatorResponseService.ApplyOptionalResponseAlteration to apply multiple independent alterations (DoB type change, Response ID injection, AuthnContextClassRef injection).
  • Added new LoggingEvents IDs for the two new attribute-injection operations.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
WebApps/Proxy/Microsoft.SPID.Proxy/Services/Implementations/FederatorResponseService.cs Adds two new alteration paths and a helper that injects new SAML attributes by cloning an existing template attribute.
WebApps/Proxy/Microsoft.SPID.Proxy/Models/Options/OptionalResponseAlterationOptions.cs Adds configuration knobs (enable flags + name/type) for the new optional injections.
WebApps/Proxy/Microsoft.SPID.Proxy/Models/LoggingEvents.cs Introduces two new event IDs for the injected-attribute logs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

mtagliaferri86
mtagliaferri86 previously approved these changes May 27, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment on lines +392 to +403
// Only set xsi:type if the template AttributeValue already had one, using the value supplied by the caller.
var existingTemplateValue = existingAttribute.ChildNodes.Cast<XmlNode>()
.FirstOrDefault(n => n.NodeType == XmlNodeType.Element && n.LocalName == "AttributeValue");
var templateTypeAttr = existingTemplateValue?.Attributes?.Cast<XmlAttribute>()
.FirstOrDefault(a => a.LocalName == "type" && a.NamespaceURI == "http://www.w3.org/2001/XMLSchema-instance");

if (templateTypeAttr != null && !string.IsNullOrWhiteSpace(xsiType))
{
var typeAttr = doc.CreateAttribute(templateTypeAttr.Prefix, "type", templateTypeAttr.NamespaceURI);
typeAttr.Value = xsiType;
attributeValueElement.Attributes.Append(typeAttr);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants