Skip to content

Commit 32248ae

Browse files
authored
Merge pull request #115 from kpadmanabhan/requested-attribute-compliance
adding sub-element for RequesedAttribute for compliance
2 parents 11bbe5a + f8ce47b commit 32248ae

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

src/ITfoxtec.Identity.Saml2/ITfoxtec.Identity.Saml2.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>net6.0;net5.0;netcoreapp3.1;netstandard2.1;net48;net462</TargetFrameworks>
3+
<TargetFrameworks>net6.0;net5.0;netcoreapp3.1;netstandard2.1;net48;net462</TargetFrameworks>
44
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
55
<Authors>Anders Revsgaard</Authors>
66
<Company>ITfoxtec</Company>

src/ITfoxtec.Identity.Saml2/Schemas/Metadata/RequestedAttribute.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,20 @@ public RequestedAttribute(string name, bool isRequired = true, string nameFormat
1414
NameFormat = nameFormat;
1515
}
1616

17+
public RequestedAttribute(string name, string attributeValue, bool isRequired = true, string nameFormat = Saml2MetadataConstants.AttributeNameFormat)
18+
: this(name, isRequired, nameFormat)
19+
{
20+
AttributeValue = attributeValue;
21+
}
22+
1723
public string Name { get; protected set; }
1824

1925
public bool IsRequired { get; protected set; }
20-
26+
2127
public string NameFormat { get; protected set; }
2228

29+
public string AttributeValue { get; protected set; }
30+
2331
public XElement ToXElement()
2432
{
2533
var envelope = new XElement(Saml2MetadataConstants.MetadataNamespaceX + elementName);
@@ -34,6 +42,13 @@ protected IEnumerable<XObject> GetXContent()
3442
yield return new XAttribute(Saml2MetadataConstants.Message.Name, Name);
3543
yield return new XAttribute(Saml2MetadataConstants.Message.NameFormat, NameFormat);
3644
yield return new XAttribute(Saml2MetadataConstants.Message.IsRequired, IsRequired);
45+
46+
if (AttributeValue != null) {
47+
var attribVal = new XElement(Saml2MetadataConstants.AttributeValueNameSpace + Saml2MetadataConstants.Message.AttributeValue) {
48+
Value = AttributeValue
49+
};
50+
yield return new XElement(attribVal);
51+
}
3752
}
3853
}
3954
}

src/ITfoxtec.Identity.Saml2/Schemas/Metadata/Saml2MetadataConstants.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public class Saml2MetadataConstants
2121

2222
public const string AttributeNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:basic";
2323
public const string AttributeNameFormatUri = "urn:oasis:names:tc:SAML:2.0:attrname-format:uri";
24+
public const string AttributeValueNameSpace = "saml:";
2425

2526
public class Message
2627
{
@@ -96,6 +97,8 @@ public class Message
9697

9798
public const string RequestedAttribute = "RequestedAttribute";
9899

100+
public const string AttributeValue = "AttributeValue";
101+
99102
public const string Name = "Name";
100103

101104
public const string NameFormat = "NameFormat";

0 commit comments

Comments
 (0)