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
2 changes: 1 addition & 1 deletion services/analytics-python-service/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def custom_openapi():
try:
engine = create_engine(DATABASE_URL)
except Exception as e:
print(f"Error creating engine: {e}")
logger.error("analytics.engine_creation_failed", extra={"error": str(e)})
engine = None

api_key = os.environ.get("OPENAI_API_KEY")
Expand Down
29 changes: 29 additions & 0 deletions services/auth-service/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1396,6 +1396,35 @@ app.post('/saml/acs', createUserRateLimiter('saml_acs', 20), async (req, res) =>
if (!signatureVerified) {
return res.status(401).json({ message: 'SAML signature verification failed' });
}

const conditions = doc.getElementsByTagNameNS
? doc.getElementsByTagNameNS('urn:oasis:names:tc:SAML:2.0:assertion', 'Conditions')
: doc.getElementsByTagName('Conditions');

if (conditions.length > 0) {
const condition = conditions[0];
const notBefore = condition.getAttribute('NotBefore');
const notOnOrAfter = condition.getAttribute('NotOnOrAfter');
const now = new Date();

if (notBefore && now < new Date(notBefore)) {
return res.status(401).json({ message: 'SAML assertion is not yet valid (NotBefore)' });
}

if (notOnOrAfter && now >= new Date(notOnOrAfter)) {
return res.status(401).json({ message: 'SAML assertion has expired (NotOnOrAfter)' });
}

const audienceNodes = doc.getElementsByTagNameNS
? doc.getElementsByTagNameNS('urn:oasis:names:tc:SAML:2.0:assertion', 'Audience')
: doc.getElementsByTagName('Audience');

for (let i = 0; i < audienceNodes.length; i++) {
if (audienceNodes[i].textContent === SAML_IDP_ENTITY_ID) {
break;
}
}
}
}

const nameIdMatch = decodedXml.match(/<saml2:NameID[^>]*>([^<]+)<\/saml2:NameID>/);
Expand Down