Skip to content

Commit 84e1ae4

Browse files
committed
Add requested value type and namespace.
1 parent 94e7641 commit 84e1ae4

File tree

7 files changed

+36
-16
lines changed

7 files changed

+36
-16
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ Support the Danish NemLog-in 2 / OIOSAML 2 and NemLog-in 3 / OIOSAML 3.</Descrip
2424
<PackageTags>SAML SAML 2.0 SAML2.0 SAML2 SAML 2 SAML-P SAMLP SSO Identity Provider (IdP) and Relying Party (RP) Authentication Metadata OIOSAML OIOSAML 2 OIOSAML 3 NemLogin NemLog-in 2 NemLog-in 3 ASP.NET MVC</PackageTags>
2525
<NeutralLanguage>en-US</NeutralLanguage>
2626
<PackageIconUrl>https://itfoxtec.com/favicon.ico</PackageIconUrl>
27-
<AssemblyVersion>4.8.3.5</AssemblyVersion>
28-
<FileVersion>4.8.3.5</FileVersion>
29-
<Copyright>Copyright © 2021</Copyright>
30-
<Version>4.8.3-beta5</Version>
27+
<AssemblyVersion>4.8.3.6</AssemblyVersion>
28+
<FileVersion>4.8.3.6</FileVersion>
29+
<Copyright>Copyright © 2022</Copyright>
30+
<Version>4.8.3-beta6</Version>
3131
<SignAssembly>true</SignAssembly>
3232
<AssemblyOriginatorKeyFile>ITfoxtec.SAML2.snk</AssemblyOriginatorKeyFile>
3333
<DelaySign>false</DelaySign>

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ Support the Danish NemLog-in 2 / OIOSAML 2 and NemLog-in 3 / OIOSAML 3.</Descrip
2828
<PackageTags>SAML SAML 2.0 SAML2.0 SAML2 SAML 2 SAML-P SAMLP SSO Identity Provider (IdP) Relying Party (RP) Authentication Metadata OIOSAML OIOSAML 2 OIOSAML 3 NemLogin NemLog-in 2 NemLog-in 3 ASP.NET MVC Core</PackageTags>
2929
<NeutralLanguage>en-US</NeutralLanguage>
3030
<PackageIconUrl>https://itfoxtec.com/favicon.ico</PackageIconUrl>
31-
<AssemblyVersion>4.8.3.5</AssemblyVersion>
32-
<FileVersion>4.8.3.5</FileVersion>
33-
<Copyright>Copyright © 2021</Copyright>
34-
<Version>4.8.3-beta5</Version>
31+
<AssemblyVersion>4.8.3.6</AssemblyVersion>
32+
<FileVersion>4.8.3.6</FileVersion>
33+
<Copyright>Copyright © 2022</Copyright>
34+
<Version>4.8.3-beta6</Version>
3535
<SignAssembly>true</SignAssembly>
3636
<AssemblyOriginatorKeyFile>ITfoxtec.SAML2.snk</AssemblyOriginatorKeyFile>
3737
<DelaySign>false</DelaySign>

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ Support the Danish NemLog-in 2 / OIOSAML 2 and NemLog-in 3 / OIOSAML 3.</Descrip
2929
<PackageTags>SAML SAML 2.0 SAML2.0 SAML2 SAML 2 SAML-P SAMLP SSO Identity Provider (IdP) Relying Party (RP) Authentication Metadata OIOSAML OIOSAML 2 OIOSAML 3 NemLogin NemLog-in 2 NemLog-in 3</PackageTags>
3030
<NeutralLanguage>en-US</NeutralLanguage>
3131
<PackageIconUrl>https://itfoxtec.com/favicon.ico</PackageIconUrl>
32-
<AssemblyVersion>4.8.3.5</AssemblyVersion>
33-
<FileVersion>4.8.3.5</FileVersion>
34-
<Copyright>Copyright © 2021</Copyright>
35-
<Version>4.8.3-beta5</Version>
32+
<AssemblyVersion>4.8.3.6</AssemblyVersion>
33+
<FileVersion>4.8.3.6</FileVersion>
34+
<Copyright>Copyright © 2022</Copyright>
35+
<Version>4.8.3-beta6</Version>
3636
<SignAssembly>true</SignAssembly>
3737
<AssemblyOriginatorKeyFile>ITfoxtec.SAML2.snk</AssemblyOriginatorKeyFile>
3838
<DelaySign>false</DelaySign>

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ protected IEnumerable<XObject> GetXContent()
135135
yield return new XAttribute(Saml2MetadataConstants.Message.ValidUntil, DateTimeOffset.UtcNow.AddDays(ValidUntil.Value).UtcDateTime.ToString(Saml2Constants.DateTimeFormat, CultureInfo.InvariantCulture));
136136
}
137137
yield return new XAttribute(Saml2MetadataConstants.MetadataNamespaceNameX, Saml2MetadataConstants.MetadataNamespace);
138-
yield return new XAttribute(Saml2MetadataConstants.SamlAssertionNamespaceNameX, Saml2MetadataConstants.SamlAssertionNamespace);
139138

140139
if (SPSsoDescriptor != null)
141140
{

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Collections.Generic;
22
using System.Xml.Linq;
3+
using System.Xml.Schema;
34

45
namespace ITfoxtec.Identity.Saml2.Schemas.Metadata
56
{
@@ -28,6 +29,10 @@ public RequestedAttribute(string name, string attributeValue, bool isRequired =
2829

2930
public string AttributeValue { get; protected set; }
3031

32+
public string AttributeValueType { get; set; } = "xs:string";
33+
34+
public string AttributeValueTypeNamespace { get; set; } = XmlSchema.InstanceNamespace;
35+
3136
public XElement ToXElement()
3237
{
3338
var envelope = new XElement(Saml2MetadataConstants.MetadataNamespaceX + elementName);
@@ -44,10 +49,17 @@ protected IEnumerable<XObject> GetXContent()
4449
yield return new XAttribute(Saml2MetadataConstants.Message.IsRequired, IsRequired);
4550

4651
if (AttributeValue != null) {
47-
var attribVal = new XElement(Saml2MetadataConstants.SamlAssertionNamespaceX + Saml2MetadataConstants.Message.AttributeValue) {
52+
var attribVal = new XElement(Saml2MetadataConstants.SamlAssertionNamespaceX + Saml2MetadataConstants.Message.AttributeValue)
53+
{
4854
Value = AttributeValue
4955
};
50-
yield return new XElement(attribVal);
56+
attribVal.Add(new XAttribute(Saml2MetadataConstants.SamlAssertionNamespaceNameX, Saml2MetadataConstants.SamlAssertionNamespace));
57+
if (!string.IsNullOrWhiteSpace(AttributeValueType) && !string.IsNullOrWhiteSpace(AttributeValueTypeNamespace))
58+
{
59+
attribVal.Add(new XAttribute(Saml2MetadataConstants.XsiNamespaceNameX, AttributeValueTypeNamespace));
60+
attribVal.Add(new XAttribute(XNamespace.Get(AttributeValueTypeNamespace) + Saml2MetadataConstants.Message.Type, AttributeValueType));
61+
}
62+
yield return attribVal;
5163
}
5264
}
5365
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Xml.Linq;
3+
using System.Xml.Schema;
34

45
namespace ITfoxtec.Identity.Saml2.Schemas.Metadata
56
{
@@ -34,6 +35,11 @@ public class Saml2MetadataConstants
3435
/// The XML namespace Name of the saml assertion.
3536
/// </summary>
3637
public static readonly XName SamlAssertionNamespaceNameX = XNamespace.Xmlns + "saml";
38+
39+
/// <summary>
40+
/// Xsi namespace name.
41+
/// </summary>
42+
public static readonly XName XsiNamespaceNameX = XNamespace.Xmlns + "xsi";
3743

3844
public const string AttributeNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:basic";
3945
public const string AttributeNameFormatUri = "urn:oasis:names:tc:SAML:2.0:attrname-format:uri";
@@ -120,6 +126,7 @@ public class Message
120126

121127
public const string IsRequired = "isRequired";
122128

129+
public const string Type = "type";
123130
}
124131

125132
public class KeyTypes

test/TestWebAppCore/Controllers/MetadataController.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public IActionResult Index()
4545
NameIDFormats = new Uri[] { NameIdentifierFormats.X509SubjectName },
4646
AssertionConsumerServices = new AssertionConsumerService[]
4747
{
48-
new AssertionConsumerService { Binding = ProtocolBindings.HttpPost, Location = new Uri(defaultSite, "Auth/AssertionConsumerService") },
48+
new AssertionConsumerService { Binding = ProtocolBindings.HttpPost, Location = new Uri(defaultSite, "Auth/AssertionConsumerService") },
4949
},
5050
AttributeConsumingServices = new AttributeConsumingService[]
5151
{
@@ -77,6 +77,8 @@ private IEnumerable<RequestedAttribute> CreateRequestedAttributes()
7777
{
7878
yield return new RequestedAttribute("urn:oid:2.5.4.4");
7979
yield return new RequestedAttribute("urn:oid:2.5.4.3", false);
80+
yield return new RequestedAttribute("urn:xxx", "test-value");
81+
yield return new RequestedAttribute("urn:yyy", "123") { AttributeValueType = "xs:integer" };
8082
}
8183
}
8284
}

0 commit comments

Comments
 (0)