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

Pass request object to validateFunc method? #25

Closed
HankMcCoy opened this issue Aug 18, 2014 · 2 comments
Closed

Pass request object to validateFunc method? #25

HankMcCoy opened this issue Aug 18, 2014 · 2 comments
Assignees
Labels
feature New functionality or improvement

Comments

@HankMcCoy
Copy link

Would it be possible to pass the request object to the validateFunc method? See my fork for a very trivial/slapdash implementation.

In my use case I'm writing a Hapi server that largely acts as a proxy to a different API. My validateFunc implementation includes a call out to this backing service to verify the user's auth token. The actual information I'm seeking to validate I'm storing in the session cookie (and thus get back as the first argument in validateFunc) but there's some other data in the request (like the user's IP address) that I'd like to forward on to the backing API for general logging/tracking purposes.

Is this a reasonable addition? Or is there some best practice I might be missing in my approach?

@hueniverse
Copy link
Contributor

The request is reasonable, but... I don't want to add arguments after the callback, and adding before the callback means a breaking change. From a security perspective, you really should not be consulting the request for validation decisions (at least not in the context of this scheme). I know you only wants to log the information but adding it opens the door for others to use it for anything.

You can instead use the 'onPostAuth' extension point in hapi to log the result of the authentication where you have full access to the request.

@hueniverse hueniverse self-assigned this Nov 12, 2014
@Marsup Marsup added feature New functionality or improvement and removed request labels Sep 21, 2019
@lock
Copy link

lock bot commented Jan 9, 2020

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature New functionality or improvement
Projects
None yet
Development

No branches or pull requests

3 participants