Skip to content

Error log verbosity enhanced #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fabriziofiorucci
Copy link
Contributor

Added HTTP Host and URI to all error logs

Copy link
Contributor

@route443 route443 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are accessing headers by index using the original casing, so the case matters here. See https://nginx.org/en/docs/njs/reference.html#r_headers_in

@@ -131,21 +131,21 @@ function validateIdTokenClaims(r, claims) {
const missingClaims = requiredClaims.filter((claim) => !claims[claim]);

if (missingClaims.length > 0) {
r.error(`OIDC ID Token validation error: missing claim(s) ${missingClaims.join(' ')}`);
r.error(`OIDC ID Token validation error for " + r.headersIn['host'] + r.uri + ": missing claim(s) ${missingClaims.join(' ')}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a copy-paste error, and r.headersIn will be logged as a literal.

return false;
}

// Audience must include the configured client
const aud = Array.isArray(claims.aud) ? claims.aud : claims.aud.split(',');
if (!aud.includes(r.variables.oidc_client)) {
r.error(`OIDC ID Token validation error: aud claim (${claims.aud}) ` +
r.error(`OIDC ID Token validation error for " + r.headersIn['host'] + r.uri + ": aud claim (${claims.aud}) ` +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here, it will be logged as a literal.

@@ -160,12 +160,12 @@ function validateIdTokenClaims(r, claims) {
: '';

if (claims.nonce !== clientNonceHash) {
r.error(`OIDC ID Token validation error: nonce from token (${claims.nonce}) ` +
r.error(`OIDC ID Token validation error for " + r.headersIn['host'] + r.uri + ": nonce from token (${claims.nonce}) ` +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will be logged as a literal

if (tokenset.error) {
r.error("OIDC " + tokenset.error + " " + tokenset.error_description);
r.error("OIDC for " + r.headersIn['host'] + r.uri + " " + tokenset.error + " " + tokenset.error_description);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like the word "error" is missing

@@ -373,7 +373,7 @@ async function handleFrontChannelLogout(r) {

const claims = await getTokenClaims(r, sessionJwt);
if (claims.iss !== requestIss) {
r.error("Issuer mismatch during logout. Received iss: " +
r.error("Issuer mismatch during logout for " + r.headersIn['host'] + r.uri + " Received iss: " +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A separator is missing

`does not match client (${clientNonceHash})`);
return false;
}
} else if (isNewSession(r)) {
r.error("OIDC ID Token validation error: " +
r.error("OIDC ID Token validation error for " + r.headersIn['host'] + r.uri + ": " +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an extra concatenation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants