Closed SachinSaxena closed 2 years ago
string samlIdentityUrl = "http://localhost:5000/Saml2"; string samlMetadataUrl = "http://localhost:5000/Saml2"; //string samlSignOnUrl = ""; string certificate = "Sustainsys.Saml2.Tests.pfx";
services.AddAuthentication().AddSaml2(options =>
{
options.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme;
options.SignOutScheme = IdentityServerConstants.DefaultCookieAuthenticationScheme;
options.SPOptions.EntityId = new EntityId(samlIdentityUrl);
options.IdentityProviders.Add(
new IdentityProvider(
new EntityId(samlMetadataUrl), options.SPOptions)
{
LoadMetadata = true
});
options.SPOptions.ServiceCertificates.Add(new X509Certificate2(certificate));
});
Looks like the metadata presented by the idp is incorrect, or at least does not contain data being expected by the library.
InvalidOperationException: Sequence contains no elements System.Linq.ThrowHelper.ThrowNoElementsException() System.Linq.Enumerable.Single(IEnumerable source)
Sustainsys.Saml2.IdentityProvider.ReadMetadataIdpDescriptor(EntityDescriptor metadata)
Sustainsys.Saml2.IdentityProvider.ReadMetadata(EntityDescriptor metadata)
Sustainsys.Saml2.IdentityProvider.DoLoadMetadata()
Sustainsys.Saml2.IdentityProvider.ReloadMetadataIfRequired()
Sustainsys.Saml2.IdentityProvider.get_SingleSignOnServiceUrl()
Sustainsys.Saml2.IdentityProvider.CreateAuthenticateRequest(Saml2Urls saml2Urls)
Sustainsys.Saml2.WebSso.SignInCommand.InitiateLoginToIdp(IOptions options, IDictionary<string, string> relayData, Saml2Urls urls, IdentityProvider idp, Uri returnUrl, HttpRequestData request)
Sustainsys.Saml2.WebSso.SignInCommand.Run(EntityId idpEntityId, string returnPath, HttpRequestData request, IOptions options, IDictionary<string, string> relayData)
Sustainsys.Saml2.WebSso.SignInCommand.Run(HttpRequestData request, IOptions options)
Sustainsys.Saml2.AspNetCore2.Saml2Handler.HandleRequestAsync()
IdentityServer4.Hosting.FederatedSignOut.AuthenticationRequestHandlerWrapper.HandleRequestAsync()
Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
IdentityServer4.Hosting.BaseUrlMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
This error is coming when i am opening the signin url from the identity server 4 with Asp.net Core.