throw FatalProfileException("Assertion did not contain time conditions.");
else if (token->getAuthenticationStatements().empty())
throw FatalProfileException("Assertion did not contain an authentication statement.");
+
// With ADFS, we only have one token, but we need to put it in a vector.
vector<const Assertion*> tokens(1,token);
const saml1::AuthenticationStatement* ssoStatement=token->getAuthenticationStatements().front();
+ // authnskew allows rejection of SSO if AuthnInstant is too old.
+ const PropertySet* sessionProps = application.getPropertySet("Sessions");
+ pair<bool,unsigned int> authnskew = sessionProps ? sessionProps->getUnsignedInt("authnskew") : pair<bool,unsigned int>(false,0);
+
+ if (authnskew.first && authnskew.second &&
+ ssoStatement->getAuthenticationInstant() && (now - ssoStatement->getAuthenticationInstantEpoch() > authnskew.second))
+ throw FatalProfileException("The gap between now and the time you logged into your identity provider exceeds the limit.");
+
// Address checking.
saml1::SubjectLocality* locality = ssoStatement->getSubjectLocality();
if (locality && locality->getIPAddress()) {
// Now we have to extract the authentication details for attribute and session setup.
// Session expiration for ADFS is purely SP-driven, and the method is mapped to a ctx class.
- const PropertySet* sessionProps = application.getPropertySet("Sessions");
pair<bool,unsigned int> lifetime = sessionProps ? sessionProps->getUnsignedInt("lifetime") : pair<bool,unsigned int>(true,28800);
if (!lifetime.first || lifetime.second == 0)
lifetime.second = 28800;
<attribute name="exportACL" type="conf:listOfStrings" default="127.0.0.1"/>\r
<attribute name="cookieName" type="conf:string"/>\r
<attribute name="cookieProps" type="conf:string"/>\r
- <attribute name="idpHistory" type="boolean" default="true"/>\r
+ <attribute name="idpHistory" type="boolean" default="false"/>\r
<attribute name="idpHistoryDays" type="unsignedInt"/>\r
<attribute name="lifetime" type="unsignedInt" default="28800"/>\r
<attribute name="timeout" type="unsignedInt" default="3600"/>\r
+ <attribute name="authnskew" type="unsignedInt"/>\r
<attribute name="checkAddress" type="boolean" default="true"/>\r
<attribute name="consistentAddress" type="boolean" default="true"/>\r
<anyAttribute namespace="##other" processContents="lax"/>\r
// With this flag on, we ignore any unsigned assertions.
pair<bool,bool> flag = settings->getBool("signedAssertions");
+ // authnskew allows rejection of SSO if AuthnInstant is too old.
+ const PropertySet* sessionProps = application.getPropertySet("Sessions");
+ pair<bool,unsigned int> authnskew = sessionProps ? sessionProps->getUnsignedInt("authnskew") : pair<bool,unsigned int>(false,0);
+
+ // Saves off error messages potentially helpful for users.
+ string contextualError;
+
for (vector<saml1::Assertion*>::const_iterator a = assertions.begin(); a!=assertions.end(); ++a) {
// Skip unsigned assertion?
if (!(*a)->getSignature() && flag.first && flag.second) {
tokens.push_back(*a);
// Save off the first valid SSO statement.
- if (!ssoStatement && !(*a)->getAuthenticationStatements().empty())
- ssoStatement = (*a)->getAuthenticationStatements().front();
+ const vector<AuthenticationStatement*>& statements = const_cast<const saml1::Assertion*>(*a)->getAuthenticationStatements();
+ for (vector<AuthenticationStatement*>::const_iterator s = statements.begin(); s!=statements.end(); ++s) {
+ if (authnskew.first && authnskew.second &&
+ (*s)->getAuthenticationInstant() && (now - (*s)->getAuthenticationInstantEpoch() > authnskew.second))
+ contextualError = "The gap between now and the time you logged into your identity provider exceeds the limit.";
+ else if (!ssoStatement) {
+ ssoStatement = *s;
+ break;
+ }
+ }
}
catch (exception& ex) {
m_log.warn("detected a problem with assertion: %s", ex.what());
}
}
- if (!ssoStatement)
- throw FatalProfileException("A valid authentication statement was not found in the incoming message.");
+ if (!ssoStatement) {
+ if (contextualError.empty())
+ throw FatalProfileException("A valid authentication statement was not found in the incoming message.");
+ throw FatalProfileException(contextualError.c_str());
+ }
// Address checking.
SubjectLocality* locality = ssoStatement->getSubjectLocality();
// Now we have to extract the authentication details for attribute and session setup.
// Session expiration for SAML 1.x is purely SP-driven, and the method is mapped to a ctx class.
- const PropertySet* sessionProps = application.getPropertySet("Sessions");
pair<bool,unsigned int> lifetime = sessionProps ? sessionProps->getUnsignedInt("lifetime") : pair<bool,unsigned int>(true,28800);
if (!lifetime.first || lifetime.second == 0)
lifetime.second = 28800;
// With this flag on, we ignore any unsigned assertions.
pair<bool,bool> flag = settings->getBool("signedAssertions");
- // Saves off IP-mismatch error message because it's potentially helpful for users.
- string addressMismatch;
+ // authnskew allows rejection of SSO if AuthnInstant is too old.
+ const PropertySet* sessionProps = application.getPropertySet("Sessions");
+ pair<bool,unsigned int> authnskew = sessionProps ? sessionProps->getUnsignedInt("authnskew") : pair<bool,unsigned int>(false,0);
+
+ // Saves off error messages potentially helpful for users.
+ string contextualError;
for (vector<saml2::Assertion*>::const_iterator a = assertions.begin(); a!=assertions.end(); ++a) {
// Skip unsigned assertion?
catch (exception& ex) {
// We save off the message if there's no SSO statement yet.
if (!ssoStatement)
- addressMismatch = ex.what();
+ contextualError = ex.what();
throw;
}
// Save off the first valid SSO statement, but favor the "soonest" session expiration.
const vector<AuthnStatement*>& statements = const_cast<const saml2::Assertion*>(*a)->getAuthnStatements();
for (vector<AuthnStatement*>::const_iterator s = statements.begin(); s!=statements.end(); ++s) {
- if (!ssoStatement || (*s)->getSessionNotOnOrAfterEpoch() < ssoStatement->getSessionNotOnOrAfterEpoch())
+ if (authnskew.first && authnskew.second && (*s)->getAuthnInstant() && (now - (*s)->getAuthnInstantEpoch() > authnskew.second))
+ contextualError = "The gap between now and the time you logged into your identity provider exceeds the limit.";
+ else if (!ssoStatement || (*s)->getSessionNotOnOrAfterEpoch() < ssoStatement->getSessionNotOnOrAfterEpoch())
ssoStatement = *s;
}
catch (exception& ex) {
// We save off the message if there's no SSO statement yet.
if (!ssoStatement)
- addressMismatch = ex.what();
+ contextualError = ex.what();
throw;
}
// Save off the first valid SSO statement, but favor the "soonest" session expiration.
const vector<AuthnStatement*>& statements = const_cast<const saml2::Assertion*>(decrypted)->getAuthnStatements();
for (vector<AuthnStatement*>::const_iterator s = statements.begin(); s!=statements.end(); ++s) {
- if (!ssoStatement || (*s)->getSessionNotOnOrAfterEpoch() < ssoStatement->getSessionNotOnOrAfterEpoch())
+ if (authnskew.first && authnskew.second && (*s)->getAuthnInstant() && (now - (*s)->getAuthnInstantEpoch() > authnskew.second))
+ contextualError = "The gap between now and the time you logged into your identity provider exceeds the limit.";
+ else if (!ssoStatement || (*s)->getSessionNotOnOrAfterEpoch() < ssoStatement->getSessionNotOnOrAfterEpoch())
ssoStatement = *s;
}
if (!ssoStatement) {
for_each(ownedtokens.begin(), ownedtokens.end(), xmltooling::cleanup<saml2::Assertion>());
- if (addressMismatch.empty())
+ if (contextualError.empty())
throw FatalProfileException("A valid authentication statement was not found in the incoming message.");
- throw FatalProfileException(addressMismatch.c_str());
+ throw FatalProfileException(contextualError.c_str());
}
// May need to decrypt NameID.
// Session expiration for SAML 2.0 is jointly IdP- and SP-driven.
time_t sessionExp = ssoStatement->getSessionNotOnOrAfter() ? ssoStatement->getSessionNotOnOrAfterEpoch() : 0;
- const PropertySet* sessionProps = application.getPropertySet("Sessions");
pair<bool,unsigned int> lifetime = sessionProps ? sessionProps->getUnsignedInt("lifetime") : pair<bool,unsigned int>(true,28800);
if (!lifetime.first || lifetime.second == 0)
lifetime.second = 28800;