SAML2 Error

SAML2 Error

by Lei Fuentes -
Number of replies: 4

Hello, 

We are currently using this plugin https://moodle.org/plugins/auth_saml2

So we successfully make SAML work on our LMS, however every day we keep on getting this error "Could not find the metadata of an IdP with entity ID 'localhost', but if we resave the settings (with the same config) it will work again with no error. Then the next day we will receive again the same issue.

I was thinking, maybe because of server cache? (Not sure though) Since I also did this scenario where SAML is working on our LMS no errors, then I remove the IDP metadata details then tried to log in again, but I did not receive any error and I successfully log in.


I checked on the backend where the error is being thrown and found this 

Directory : /saml2/extlib/simplesamlphp/modules/saml/lib/Auth/Source/SP.php

Line 108-136

    public function getIdPMetadata($entityId) {
        assert('is_string($entityId)');
        if ($this->idp !== NULL && $this->idp !== $entityId) {
            throw new SimpleSAML_Error_Exception('Cannot retrieve metadata for IdP ' . var_export($entityId, TRUE) .
                ' because it isn\'t a valid IdP for this SP.');
        }
        $metadataHandler = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
        // First, look in saml20-idp-remote.
        try {
            return $metadataHandler->getMetaDataConfig($entityId, 'saml20-idp-remote');
        } catch (Exception $e) {
            /* Metadata wasn't found. */
SimpleSAML\Logger::debug('getIdpMetadata: ' . $e->getMessage());
        }
        /* Not found in saml20-idp-remote, look in shib13-idp-remote. */
        try {
            return $metadataHandler->getMetaDataConfig($entityId, 'shib13-idp-remote');
        } catch (Exception $e) {
            /* Metadata wasn't found. */
SimpleSAML\Logger::debug('getIdpMetadata: ' . $e->getMessage());
        }
        /* Not found. */
        throw new SimpleSAML_Error_Exception('Could not find the metadata of an IdP with entity ID ' . var_export($entityId, TRUE));
    }

I found two options the code is trying to look to get the metadata config, I was thinking that maybe there's another option that can be added to the code that can cater to the problem above.


Thanks for the help.





Average of ratings: -
In reply to Lei Fuentes

Re: SAML2 Error

by Lei Fuentes -

I think I found the error. 

Our metadata has expiry and expire every 1378 seconds

In reply to Lei Fuentes

Re: SAML2 Error

by Bryan Blackwell -

Hi Lei -

We are experiencing this exact issue.  Do you mind sharing in more detail about the metadata expiration?  Was that on the Moodle side or your IdP?

Thanks,
Bryan

In reply to Bryan Blackwell

Re: SAML2 Error

by Arnel Jr. Rubiano -

HI Lei

Good day!

We are experiencing it also. Kindly share your solution.

Thanks in advance.


Best Regards,

Arnel