Skip to content
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

Logging and misc improvements #133

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sseppola
Copy link

@sseppola sseppola commented Nov 3, 2021

Hi, we've been playing around with this for a couple of days now and made some improvements you may want. They're mainly concerning logging to allow us to figure out what was happening on our end.

We found that if scope was only "openid offline_access" then of course no access_token is issued. While not a big problem access_token = null caused access_token_assertions to throw an error. I added a check and a log entry in order to handle it gracefully, then did the same for id_token in case someone don't have openid in the scope.

Lastly, like we discussed in #131 we got a domain mydomain.comundefined because x-forwarded-uri was assumed to have a value. So we added a fallback value as it's better to have no path than mess up the domain.

@travisghansen
Copy link
Owner

Thanks for the contribution! I'll look a little more closely when I have a moment and provide some feedback.

Copy link
Owner

@travisghansen travisghansen left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! That's a lot of logging ;)

}

if (
pluginStrategy == PLUGIN_STRATEGY_OIDC &&
Copy link
Owner

Choose a reason for hiding this comment

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

This check needs to remain.

Copy link
Author

Choose a reason for hiding this comment

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

Can you elaborate on this? We use OAuth2 and need it to validate nbf and iss.

}

if (
pluginStrategy == PLUGIN_STRATEGY_OIDC &&
Copy link
Owner

Choose a reason for hiding this comment

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

This check needs to remain.

}

if (
pluginStrategy == PLUGIN_STRATEGY_OIDC &&
Copy link
Owner

Choose a reason for hiding this comment

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

This check needs to remain.

Copy link
Author

Choose a reason for hiding this comment

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

I don't understand this, is id_token assertions not available in OAuth2?

}

if (
pluginStrategy == PLUGIN_STRATEGY_OIDC &&
Copy link
Owner

Choose a reason for hiding this comment

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

This check needs to remain.

plugin.config.assertions.access_token
) {
let accessToken;
accessToken = jwt.decode(tokenSet.access_token);
Copy link
Owner

Choose a reason for hiding this comment

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

Was this the line that was blowing up previously? Or was it something else?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, I believe the decode function doesn't handle undefined inputs

@@ -188,7 +188,7 @@ function get_parent_request_uri(req) {
originalRequestURI = originalRequestURI.replace(/^(.+?)\/*?$/, "$1"); // remove all trailing slashes
originalRequestURI += req.headers["x-forwarded-uri"];
} else {
originalRequestURI += req.headers["x-forwarded-uri"];
originalRequestURI += req.headers["x-forwarded-uri"] || '';
Copy link
Owner

Choose a reason for hiding this comment

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

I'll think about this change. It should be handled differently but not sure how exactly :( it probably needs to throw an error if missing as the data is critical to function properly.

Copy link
Author

Choose a reason for hiding this comment

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

Ok, throwing a hard error is much better than it being undefined as you'll be able to identify the problem quickly.

@sseppola sseppola mentioned this pull request Feb 7, 2022
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