Giter Site home page Giter Site logo

Comments (15)

jaw187 avatar jaw187 commented on June 15, 2024

No, will not have access to the request. But you could use a combination of auth and the onPreAuth or onPostAuth extension points. http://hapijs.com/api#serverextevent-method-options

from cookie.

jardakotesovec avatar jardakotesovec commented on June 15, 2024

And what is the reason not having access to the request in validateFunc? I think getting some details from request is reasonable use-case.

We have bit different use case - where we have database connection handler per request, which is accessible from request object - so it would be handy for us to be able to access the request object.

from cookie.

jaw187 avatar jaw187 commented on June 15, 2024

Is that database connection going to be used to validate the request?

from cookie.

jardakotesovec avatar jardakotesovec commented on June 15, 2024

It would be used to validate that token inside cookie is still valid - by checking sessions in database.

from cookie.

jardakotesovec avatar jardakotesovec commented on June 15, 2024

To provide bit more context - we are using hapi-node-postgres, which provide connection from pool to every request and return connection back to the pool once request is finished.

from cookie.

jaw187 avatar jaw187 commented on June 15, 2024

Is there anyway to define the validation function such that it has a reference to the connection pool? If not, the only solution is to change the signature of validateFunc to include request.

from cookie.

jardakotesovec avatar jardakotesovec commented on June 15, 2024

Do you think that passing request as last parameter would be acceptable? It would not be breaking change and it would help for use cases when you need to access request object.

from cookie.

jaw187 avatar jaw187 commented on June 15, 2024

@hueniverse Do you have any concerns about passing the request object to
validateFunc?

On Mon, May 25, 2015, 4:35 AM Jarda Kotฤ›ลกovec [email protected]
wrote:

Do you think that passing request as last parameter would be acceptable?
It would not be breaking change and it would help for use cases when you
need to access request object.

โ€”
Reply to this email directly or view it on GitHub
#58 (comment)
.

from cookie.

hueniverse avatar hueniverse commented on June 15, 2024

No, just need to find a way to minimize breaking changes. Not sure this is worth an option but this is a heavily used module and most people don't need this.

from cookie.

jaw187 avatar jaw187 commented on June 15, 2024

@hueniverse If most people don't need this, is there a more common pattern for validating the session against a database while using a connection pool shared by the entire app?

@jardakotesovec Instead of adding it as the last argument, adding it as an optional argument makes more sense to me. Would you like to throw together a PR? If not, let me know and I'll put something together.

from cookie.

jardakotesovec avatar jardakotesovec commented on June 15, 2024

@jaw187 Not sure how you would make it as optional argument - based on some option? Maybe it could be passed via this like settings.validateFunc(...).bind({request: request}), so it would be accessible via this.request. What do you think? That would not cause any breaking change nor require new options.

And if you could look into it that would be awesome.. ๐Ÿ‘

from cookie.

hueniverse avatar hueniverse commented on June 15, 2024

I have a feeling we need to make this change across the three auth modules and just suck up the breaking changes. Maybe line it up with the upcoming hapi 9.0 which will include a few minor breaking changes. People have asked for access to the request object over the years but never enough to make me reconsider but maybe now is the time to change this.

from cookie.

jaw187 avatar jaw187 commented on June 15, 2024

Ok. @hueniverse would you prefer multiple arguments or a single options argument?

from cookie.

hueniverse avatar hueniverse commented on June 15, 2024

other than adding request is there anything else? options implies optional.

from cookie.

lock avatar lock commented on June 15, 2024

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.

from cookie.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.