Skip to content

Commit a98cf20

Browse files
committed
Metadata read AssertionConsumerService IsDefault and Index.
1 parent 4cf2760 commit a98cf20

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ public class AssertionConsumerService
3434
/// </summary>
3535
public bool IsDefault { get; set; } = true;
3636

37+
/// <summary>
38+
/// [Calculated]
39+
/// A required attribute that assigns a unique integer value to the endpoint so that it can be
40+
/// referenced in a protocol message.
41+
/// </summary>
42+
public int Index { get; internal set; }
43+
3744
public XElement ToXElement(int index)
3845
{
3946
var envelope = new XElement(Saml2MetadataConstants.MetadataNamespaceX + elementName);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ protected IEnumerable<AssertionConsumerService> ReadAcsService(XmlNodeList acsEl
148148
{
149149
Binding = singleLogoutServiceElement.Attributes[Saml2MetadataConstants.Message.Binding].GetValueOrNull<Uri>(),
150150
Location = singleLogoutServiceElement.Attributes[Saml2MetadataConstants.Message.Location].GetValueOrNull<Uri>(),
151+
IsDefault = singleLogoutServiceElement.Attributes[Saml2MetadataConstants.Message.IsDefault].GetValueOrNull<bool>(),
152+
Index = singleLogoutServiceElement.Attributes[Saml2MetadataConstants.Message.Index].GetValueOrNull<int>(),
151153
};
152154
}
153155
}

test/TestIdPCore/Controllers/AuthController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ private RelyingParty ValidateRelyingParty(string issuer)
147147
if (entityDescriptor.SPSsoDescriptor != null)
148148
{
149149
rp.Issuer = entityDescriptor.EntityId;
150-
rp.SingleSignOnDestination = entityDescriptor.SPSsoDescriptor.AssertionConsumerServices.First().Location;
150+
rp.SingleSignOnDestination = entityDescriptor.SPSsoDescriptor.AssertionConsumerServices.Where(a => a.IsDefault).OrderBy(a => a.Index).First().Location;
151151
var singleLogoutService = entityDescriptor.SPSsoDescriptor.SingleLogoutServices.First();
152152
rp.SingleLogoutResponseDestination = singleLogoutService.ResponseLocation ?? singleLogoutService.Location;
153153
rp.SignatureValidationCertificate = entityDescriptor.SPSsoDescriptor.SigningCertificates.First();

test/TestWebAppCore/Controllers/MetadataController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ public IActionResult Index()
4646
NameIDFormats = new Uri[] { NameIdentifierFormats.X509SubjectName },
4747
AssertionConsumerServices = new AssertionConsumerService[]
4848
{
49-
new AssertionConsumerService { Binding = ProtocolBindings.HttpPost, Location = new Uri(defaultSite, "Auth/AssertionConsumerService") }
49+
new AssertionConsumerService { Binding = ProtocolBindings.HttpPost, Location = new Uri(defaultSite, "Auth/AssertionConsumerService") },
50+
new AssertionConsumerService { Binding = ProtocolBindings.HttpPost, Location = new Uri(defaultSite, "Auth/AssertionConsumerService-test"), IsDefault = false }
5051
},
5152
AttributeConsumingServices = new AttributeConsumingService[]
5253
{

0 commit comments

Comments
 (0)