Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,8 @@ private void HandleDeleteIdp(string filename)
private void HandleUpdateIdp(string filename)
{
var metadataDoc = ParseFile(filename);
if (metadataDoc == null)
return; // Not a SAML 2.0 metadata file - ignore it instead of failing.
// First we try and find the endpoint based on the entity id in the metadata
var endp = FindEndPoint(metadataDoc.EntityId);
if (endp == null && _fileToEntity.ContainsKey(filename))
Expand All @@ -501,6 +503,8 @@ private void HandleCreateIdp(string filename)
if (!_fileToEntity.ContainsKey(filename))
{
var metadataDoc = ParseFile(filename);
if (metadataDoc == null)
return; // Not a SAML 2.0 metadata file (e.g. a README placed in the metadata directory) - ignore it instead of failing.
var endp = FindEndPoint(metadataDoc.EntityId);
if (endp == null) // If the endpoint does not exist, create it.
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ AppID={1}</value>
<value>The specified metadata directory "{0}" could not be located.</value>
</data>
<data name="MetadataNotFound" xml:space="preserve">
<value>Metadata not found for idp endpoint with id {0}</value>
<value>No metadata was found for the configured IDPEndpoint with id "{0}". Verify that the id matches the entityID of a metadata file in the configured metadata directory (a misspelled id is the most common cause).</value>
</data>
<data name="NoAttributeValuePresent" xml:space="preserve">
<value>Xml error: attribute {0} of element {1}: {2} must have a value.</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using dk.nita.saml20.Properties;
using dk.nita.saml20.Schema.Protocol;
using dk.nita.saml20.Utils;
using Saml2.Properties;
using Trace = dk.nita.saml20.Utils.Trace;

namespace dk.nita.saml20.protocol
Expand Down Expand Up @@ -142,6 +143,11 @@ public IDPEndPoint RetrieveIDP(HttpContext context)
var defaultIdp = config.Endpoints.IDPEndPoints.Find(idp => idp.Default);
if (defaultIdp != null)
{
// A configured endpoint has no metadata when no metadata file matches its id (typically a misspelled
// id). Fail with a clear message instead of the opaque NullReferenceException that follows downstream.
if (defaultIdp.metadata == null)
throw new Saml20Exception(string.Format(Resources.MetadataNotFound, defaultIdp.Id));

if (Trace.ShouldTrace(TraceEventType.Information))
Trace.TraceData(TraceEventType.Information, "Using IdP marked as default: " + defaultIdp.Id);

Expand Down
Loading