Skip to content

Commit

Permalink
Merge pull request #212 from ITfoxtec/scoping-bug
Browse files Browse the repository at this point in the history
Remove local repeated namespace from `Scoping`, `IDPList` and `IDPEnt…
  • Loading branch information
Revsgaard authored Jun 17, 2024
2 parents 2c629d0 + d807745 commit 6106259
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ Support the Danish NemLog-in 2 / OIOSAML 2 and NemLog-in 3 / OIOSAML 3.</Descrip
<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>
<NeutralLanguage>en-US</NeutralLanguage>
<PackageIconUrl>https://itfoxtec.com/favicon.ico</PackageIconUrl>
<AssemblyVersion>4.11.1</AssemblyVersion>
<FileVersion>4.11.1</FileVersion>
<AssemblyVersion>4.11.3</AssemblyVersion>
<FileVersion>4.11.3</FileVersion>
<Copyright>Copyright © 2024</Copyright>
<Version>4.11.1</Version>
<Version>4.11.3</Version>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>ITfoxtec.SAML2.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ Support the Danish NemLog-in 2 / OIOSAML 2 and NemLog-in 3 / OIOSAML 3.</Descrip
<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>
<NeutralLanguage>en-US</NeutralLanguage>
<PackageIconUrl>https://itfoxtec.com/favicon.ico</PackageIconUrl>
<AssemblyVersion>4.11.1</AssemblyVersion>
<FileVersion>4.11.1</FileVersion>
<AssemblyVersion>4.11.3</AssemblyVersion>
<FileVersion>4.11.3</FileVersion>
<Copyright>Copyright © 2024</Copyright>
<Version>4.11.1</Version>
<Version>4.11.3</Version>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>ITfoxtec.SAML2.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
Expand Down
6 changes: 3 additions & 3 deletions src/ITfoxtec.Identity.Saml2/ITfoxtec.Identity.Saml2.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ Support the Danish NemLog-in 2 / OIOSAML 2 and NemLog-in 3 / OIOSAML 3.</Descrip
<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>
<NeutralLanguage>en-US</NeutralLanguage>
<PackageIconUrl>https://itfoxtec.com/favicon.ico</PackageIconUrl>
<AssemblyVersion>4.11.1</AssemblyVersion>
<FileVersion>4.11.1</FileVersion>
<AssemblyVersion>4.11.3</AssemblyVersion>
<FileVersion>4.11.3</FileVersion>
<Copyright>Copyright © 2024</Copyright>
<Version>4.11.1</Version>
<Version>4.11.3</Version>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>ITfoxtec.SAML2.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
Expand Down
4 changes: 1 addition & 3 deletions src/ITfoxtec.Identity.Saml2/Schemas/IDPEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ public XElement ToXElement()
}

protected virtual IEnumerable<XObject> GetXContent()
{
yield return new XAttribute(Saml2Constants.ProtocolNamespaceNameX, Saml2Constants.ProtocolNamespaceX);

{
if (ProviderID != null)
{
yield return new XAttribute(Saml2Constants.Message.ProviderID, ProviderID);
Expand Down
6 changes: 2 additions & 4 deletions src/ITfoxtec.Identity.Saml2/Schemas/IDPList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,10 @@ public XElement ToXElement()
}

protected virtual IEnumerable<XObject> GetXContent()
{
yield return new XAttribute(Saml2Constants.ProtocolNamespaceNameX, Saml2Constants.ProtocolNamespaceX);

{
if (GetComplete != null)
{
yield return new XAttribute(Saml2Constants.Message.GetComplete, GetComplete);
yield return new XElement(Saml2Constants.Message.GetComplete, GetComplete);
}

if (IDPEntry != null)
Expand Down
4 changes: 1 addition & 3 deletions src/ITfoxtec.Identity.Saml2/Schemas/Scoping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,11 @@ public XElement ToXElement()

protected virtual IEnumerable<XObject> GetXContent()
{
yield return new XAttribute(Saml2Constants.ProtocolNamespaceNameX, Saml2Constants.ProtocolNamespaceX);

if (RequesterID != null)
{
foreach (var item in RequesterID)
{
yield return new XAttribute(Saml2Constants.Message.RequesterID, item);
yield return new XElement(Saml2Constants.Message.RequesterID, item);
}
}

Expand Down
7 changes: 7 additions & 0 deletions src/ITfoxtec.Identity.Saml2/Util/GenericTypeConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ internal static T ConvertElement<T>(XmlNode xmlNode)
Comparison = ConvertValue<AuthnContextComparisonTypes>(xmlNode.Attributes[Schemas.Saml2Constants.Message.Comparison]?.Value, xmlNode),
});
}
else if (genericType == typeof(Scoping))
{
return GenericConvertValue<T, Scoping>(new Scoping
{
RequesterID = GetAuthnContextClassRef(xmlNode.SelectNodes($"//*[local-name()='{Schemas.Saml2Constants.Message.RequesterID}']")),
});
}
else
{
throw new NotSupportedException($"Unable to convert element {genericType}.");
Expand Down
14 changes: 14 additions & 0 deletions test/TestWebAppCore/Controllers/AuthController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ public IActionResult Login(string returnUrl = null)
// Comparison = AuthnContextComparisonTypes.Exact,
// AuthnContextClassRef = new string[] { AuthnContextClassTypes.PasswordProtectedTransport.OriginalString },
//},
Scoping = new Scoping
{
IDPList = new IDPList
{
IDPEntry = [new IDPEntry
{
ProviderID = "https://qaz.org",
Name = "xxx",
Loc = "https://wsx.org"
}],
GetComplete = "xxx"
},
RequesterID = ["https://xyz.org"]
}
}).ToActionResult();
}

Expand Down

0 comments on commit 6106259

Please sign in to comment.