Comments (15)
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.
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.
Is that database connection going to be used to validate the request?
from cookie.
It would be used to validate that token inside cookie is still valid - by checking sessions in database.
from cookie.
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.
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.
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.
@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.
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.
@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.
@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.
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.
Ok. @hueniverse would you prefer multiple arguments or a single options
argument?
from cookie.
other than adding request
is there anything else? options
implies optional.
from cookie.
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)
- After upgrading from 9.1.0 to 10.0.0 on hapi 18.1.0 getting strange behaviour for plugin HOT 2
- request.auth.credentials is null after setting request.cookieAuth.set({ id: users.id }); HOT 3
- Change module namespace HOT 1
- Update to README HOT 3
- Bug in readme.md (example code) HOT 2
- Very long password can break cookies HOT 2
- Server-side-only session attributes to avoid cookies exceed size HOT 2
- Action required: Greenkeeper could not be activated ๐จ HOT 1
- Update deps HOT 1
- Update joi HOT 1
- Only node 12
- Non system error in validateFunc will be swallowed HOT 1
- Document requirement for cookie path when using paths other than /login HOT 2
- validateFunc function not called when i load my react application with webserver (Hapi js) inside Iframe
- hapi js social login session management HOT 1
- How to Return cookie value from cookie_jar file as string
- Use two different cookies for different consumer services
- Does Boom.unauthorized in validate method cause HAPI handler to slow down? HOT 1
- Support for Non-401 Error Codes from the validateFunc HOT 2
- Version 12.0.0 breaking changes? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cookie.