-
-
Notifications
You must be signed in to change notification settings - Fork 594
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 Bearer token as query request option #1528
Comments
Thanks for opening this issue!
|
I am willing to provide a PR for this, if this seems like a good idea to add, @mtrezza ? |
Another idea would be to add myQuery.save(null, { customHeaders: { Authorization: 'Bearer abc123', 'X-Something': 'Whooops' } }); |
How does parse-community/parse-server#7079 play into this? I think any auth-related change should be seen in that context, because that PR will likely get merged soon. |
To be honest, I can't put the two into a directly related context. I am not entirely sure what parse-community/parse-server#7079 solves in this regard. Maybe @Moumouls can weigh in on this. But given the latest comments on the PR, it also didn't look like it's going to get merged soon? The idea described here is about adding the As proposed in my other comment, I am open for implementing this in a more general fashion as |
So it's like #1014 but you want to set custom headers as a request (query) parameter? If so, I think we can leverage existing logic (e.g. allow-listing custom headers server side). |
Yes. It is like #1014 but I absolutely want to avoid using Our users authenticate via JWT token (provided by an Azure service) and Parse.User objects have no related session in our setup - as the JWT token is validated on each request. This works fine to to restrict access to cloud functions. But now, we want to run queries via the JS SDK in the cloud function within the user context, because we also want to use ACLs. Normally, you could pass the user's session token as option, which is then added as a HTTP header by the SDK for the request. But we do not have a session token. It would work fine though if I could simply add the user's JWT token (which is available in the cloud function request) to the HTTP call of the query inside the cloud function - just like the session token. As the user context is different for each Cloud function run, we don't want to user Probably, I could also use the user's JWT token as session token and implement a workaround on server side with a request interceptor/middleware that takes |
Got it I think it makes sense. |
1 similar comment
Got it I think it makes sense. |
Cool, which proposal do you see more fitting? In #1529 I chose the simple way now but even supporting any custom headers wouldn't be much work. I am just not sure if it's really needed here for now. |
If a more general custom header option would make a specific custom auth header option unnecessary, we should probably go for the general option:
|
Yep, I see the benefits. I will update the PR accordingly. |
Amazing, if you need any support, please request! |
New Feature / Enhancement Checklist
Current Limitation
We are using JWT based authentication (parse-community/parse-server#6411) on server side together. Currently, we do not create Parse Sessions anymore as they are not needed. We are using cloud functions, which works fine with the JWT approach but one downside is that it is not easy to run the cloud function in the user context because we have no
sessionToken
to pass to the SDK. We could useCoreManager
to set the Auth token, but it is set globally which we want to avoid in Cloud context where requests are made in multiple user contexts. If we don't reset the code properly, another request might use the token from another user...not to speak of concurrency issues in general with that approach. I proposed request interceptors as a new feature in #1449 which would tackle the same problem but now thought of a different way which would make it especially easier for cloud functions.Feature / Enhancement Description
It is possible to pass a session token to the
Parse.Query
call via options:This token is added to the request as a
X-Parse-Session-Token
header and interpreted on server side.The idea is now to add another option,
authorizationHeader
tooptions
which is then simply added asAuthoriation
header to the request. Parse Server would then validate this bearer token like a usual request and use the JWT functionality.If I am not mistaken, the change would be fairly simple and only touch
RestController.js
+ tests.Example Use Case
This would allow us in Cloud functions to simply pass the auth header of the request along to the new request.
Alternatives / Workarounds
CoreManager
-> Not a good idea3rd Party References
The text was updated successfully, but these errors were encountered: