-
-
Notifications
You must be signed in to change notification settings - Fork 751
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
Redirect from Service / Use hooks with custom middleware #374
Comments
I think there is a workaround how to check the token and get the user in #357. You basically create your own middleware that decodes the token and then grabs the user from the user service and tacks it on the request. In fact, you can probably just copy the decode-token and populate user Express middleware from the passwordless branch, it pretty much does exactly that. I am going to close this since it is the same as #357 and will be covered in the next version of feathers-authentication (for the 1.0 discussion see feathersjs-ecosystem/authentication#226). |
Really need to know how to do the same! I am planning to secure nginx public path using feathers. Appreciate pointer how to do this. Thanks! |
This is all documented now in https://docs.feathersjs.com/guides/auth/recipe.express-middleware.html |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue with a link to this issue for related bugs. |
I want to use my feathers app to manage authorization on static resources served by
nginx
. Using middleware this is easily possible by using theX-Accel-Redirect
header:For the time being (I know that this will probably change with
1.0
- feather-authentication # 227) authentication hooks are the only way I know of to ensure a user is authenticated, get his user object, and do some custom auth-logic (can this use access this resource?).So I am thinking that while the
passwordless
branch isn't merged I have to either:req
andres
objects, orThe first option does not seem to work because, while it says in the docs that hooks are just small middleware functions, using them like express middleware does not work (
hook.type
not set, not calling or even having access tonext
). Am I not seeing something here? Is there an easy way to register andapp.use
hooks like middleware and daisy-chain them in front of custom middleware?There doesn't seem to be a way to access the
res
andreq
objects in services. How would one go about implementing a redirect within a service?Note:
I have tried chaining a service (which basically does nothing) and my custom middleware that executed the redirect together in one route (ex1) to facilitate using the authentication hook as before hooks to the service and then have the middleware work the request. But the request hangs and the custom middleware never gets executed.
The text was updated successfully, but these errors were encountered: