Skip to content

Commit

Permalink
Merge pull request #167 from ITfoxtec/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
Revsgaard authored Jan 15, 2024
2 parents 55769fa + 470346a commit a8d2d34
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 12 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.10.7.0</AssemblyVersion>
<FileVersion>4.10.7.0</FileVersion>
<AssemblyVersion>4.10.8.0</AssemblyVersion>
<FileVersion>4.10.8.0</FileVersion>
<Copyright>Copyright © 2023</Copyright>
<Version>4.10.7.0</Version>
<Version>4.10.8.0</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 @@ -31,10 +31,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.10.7.0</AssemblyVersion>
<FileVersion>4.10.7.0</FileVersion>
<AssemblyVersion>4.10.8.0</AssemblyVersion>
<FileVersion>4.10.8.0</FileVersion>
<Copyright>Copyright © 2023</Copyright>
<Version>4.10.7.0</Version>
<Version>4.10.8.0</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 @@ -32,10 +32,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.10.7.0</AssemblyVersion>
<FileVersion>4.10.7.0</FileVersion>
<AssemblyVersion>4.10.8.0</AssemblyVersion>
<FileVersion>4.10.8.0</FileVersion>
<Copyright>Copyright © 2023</Copyright>
<Version>4.10.7.0</Version>
<Version>4.10.8.0</Version>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>ITfoxtec.SAML2.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
Expand Down
11 changes: 11 additions & 0 deletions src/ITfoxtec.Identity.Saml2/Schemas/Metadata/EntityDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ public string IdAsString
/// </summary>
public IdPSsoDescriptor IdPSsoDescriptor { get; set; }

/// <summary>
/// [Optional]
/// Optional element specifying the organization associated with the entity described by the metadata.
/// </summary>
public Organization Organization { get; set; }

/// <summary>
/// [Optional]
/// Optional element identifying various kinds of contact personnel.
Expand Down Expand Up @@ -146,6 +152,11 @@ protected IEnumerable<XObject> GetXContent()
yield return IdPSsoDescriptor.ToXElement();
}

if (Organization != null)
{
yield return Organization.ToXElement();
}

if (ContactPersons != null)
{
foreach (var contactPerson in ContactPersons)
Expand Down
67 changes: 67 additions & 0 deletions src/ITfoxtec.Identity.Saml2/Schemas/Metadata/Organization.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
using System.Collections.Generic;
using System.Xml.Linq;

namespace ITfoxtec.Identity.Saml2.Schemas.Metadata
{
/// <summary>
/// The Organization element specifies basic contact information about the company or organization that is publishing the metadata document.
/// The use of this element is always optional. Its content is informative in
/// nature and does not directly map to any core SAML elements or attributes.
/// </summary>
public class Organization
{
const string elementName = Saml2MetadataConstants.Message.Organization;

public Organization(string name, string displayName, string url)
{
OrganizationName = name;
OrganizationDisplayName = displayName;
OrganizationURL = url;
}

/// <summary>
/// [Required]
/// Specifies the name of the organization responsible for the SAML entity or role.
/// </summary>
public string OrganizationName { get; protected set; }

/// <summary>
/// [Required]
/// OrganizationDisplayName is an optional string element that specifies the display name of the organization.
/// </summary>
public string OrganizationDisplayName { get; protected set; }

/// <summary>
/// [Required]
/// OrganizationURL is an optional anyURI element that specifies the URL of the organization.
/// </summary>
public string OrganizationURL { get; protected set; }

public XElement ToXElement()
{
var envelope = new XElement(Saml2MetadataConstants.MetadataNamespaceX + elementName);

envelope.Add(GetXContent());

return envelope;
}

protected IEnumerable<XObject> GetXContent()
{
if (OrganizationName != null)
{
yield return new XElement(Saml2MetadataConstants.MetadataNamespaceX + Saml2MetadataConstants.Message.OrganizationName, OrganizationName);
}

if (OrganizationDisplayName != null)
{
yield return new XElement(Saml2MetadataConstants.MetadataNamespaceX + Saml2MetadataConstants.Message.OrganizationDisplayName, OrganizationDisplayName);
}

if (OrganizationURL != null)
{
yield return new XElement(Saml2MetadataConstants.MetadataNamespaceX + Saml2MetadataConstants.Message.OrganizationURL, OrganizationURL);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ public class Message

public const string SPSsoDescriptor = "SPSSODescriptor";

public const string IdPSsoDescriptor = "IDPSSODescriptor";
public const string IdPSsoDescriptor = "IDPSSODescriptor";

public const string Organization = "Organization";

public const string ContactPerson = "ContactPerson";

Expand Down Expand Up @@ -129,7 +131,13 @@ public class Message

public const string Type = "type";

public const string FriendlyName = "FriendlyName";
public const string FriendlyName = "FriendlyName";

public const string OrganizationName = "OrganizationName";

public const string OrganizationDisplayName = "OrganizationDisplayName";

public const string OrganizationURL = "OrganizationURL";
}

public class KeyTypes
Expand Down
4 changes: 3 additions & 1 deletion test/TestIdPCore/Controllers/AuthController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ private IActionResult LoginPostResponse(Saml2Id inResponseTo, Saml2StatusCodes s
//saml2AuthnResponse.NameId = new Saml2NameIdentifier(claimsIdentity.Claims.Where(c => c.Type == ClaimTypes.NameIdentifier).Select(c => c.Value).Single());
saml2AuthnResponse.ClaimsIdentity = claimsIdentity;

var token = saml2AuthnResponse.CreateSecurityToken(relyingParty.Issuer, /*declAuthnContext: new Uri("urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified"),*/ subjectConfirmationLifetime: 5, issuedTokenLifetime: 60);


var token = saml2AuthnResponse.CreateSecurityToken(relyingParty.Issuer, /*authnContext: new Uri("urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport"),*/ /*declAuthnContext: new Uri("urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified"),*/ subjectConfirmationLifetime: 5, issuedTokenLifetime: 60);
}

return responsebinding.Bind(saml2AuthnResponse).ToActionResult();
Expand Down
1 change: 1 addition & 0 deletions test/TestIdPCore/Controllers/MetadataController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public IActionResult Index()
new SamlAttribute("urn:oid:1.3.6.1.4.1.5923.1.1.1.1", new string[] { "member", "student", "employee" })
}
};
entityDescriptor.Organization = new Organization("Some Organization", "Some Organization Display Name", "http://some-organization.com");
entityDescriptor.ContactPersons = new[] {
new ContactPerson(ContactTypes.Administrative)
{
Expand Down
1 change: 1 addition & 0 deletions test/TestWebAppCore/Controllers/MetadataController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public IActionResult Index()
new AttributeConsumingService { ServiceName = new ServiceName("Some SP", "en"), RequestedAttributes = CreateRequestedAttributes() }
},
};
entityDescriptor.Organization = new Organization("Some Organization", "Some Organization Display Name", "http://some-organization.com");
entityDescriptor.ContactPersons = new[] {
new ContactPerson(ContactTypes.Administrative)
{
Expand Down

0 comments on commit a8d2d34

Please sign in to comment.