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 4 commits 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

@@ -56,10 +56,10 @@ async function codeExchange(r) {
// Check authorization code presence
if (!r.variables.arg_code || r.variables.arg_code.length == 0) {
if (r.variables.arg_error) {
r.error("OIDC error receiving authorization code: " +
r.error("OIDC error receiving authorization code 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.

I pointed this out in the main comment:
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

Copy link
Contributor

Choose a reason for hiding this comment

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

For template literals, it’s better to use the headersIn.foo approach.

@@ -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.

In this and similar cases, it’s better to follow a consistent stylistic approach

Copy link
Contributor

Choose a reason for hiding this comment

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

This hasn’t been fixed.

return false;
}

// Check 'iat' validity
const iat = Math.floor(Number(claims.iat));
if (String(iat) !== claims.iat || iat < 1) {
r.error("OIDC ID Token validation error: iat claim is not a valid number");
r.error(`OIDC ID Token validation error for ` + r.headersIn['Host'] + r.uri + `: iat claim is not a valid number`);
Copy link
Contributor

Choose a reason for hiding this comment

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

When I talk about style, this spot is a good example. Here you switched to template literals, but in #L168 you are using string concatenation under the same circumstances. Was this done for a reason I didn’t notice?

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