-
-
Notifications
You must be signed in to change notification settings - Fork 472
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
Fixed #86. Carry parameters set in scope checking further along #87
Conversation
What if at, L165 you inserted:
(The Essentially, this means that if it is not immediate, there is no response, but here's some extra info to carry through the transaction. As I mentioned, I think its confusing to say there's a "response" when the user has not actually made one. There should be some clear distinction between the data being supplied in the immediate vs. non-immediate case. Would that work? |
That sounds great. |
So it turns out that that naming it
See the dilemma? I personally think that it's very reasonable to pass around an incomplete response object as the response is being built. That's the reason that you have Let me know your thoughts and I'll move forward as you wish. I'll also go back and see if I read anything wrong and there's another way... P.S. I didn't know what |
Actually, as far as I can tell And I'm trying to work around the variable being named info. I'll push the changes on a separate branch so you can see, but it definitely fields a little weird - or at least it did until I realized that UPDATED: that was stupid of me to say. I can't find anywhere where it is set, but it's obviously set because in the other issue I was |
This all sounds way too complicated, and I'll need to reread this thread again to understand completely I do want to make one point though: it is not safe to use the requested scope when issuing a response, unless it is equal to or lesser than a previously granted authorization So, you shouldn't be using the scope requested by the application when processing the user decision. There's a prior issue where this was discussed that I'll dig up Sent from my iPhone
|
Yeah, I'm just getting confused trying to trace down where I would make I know it's not safe to use the requested scope, which is why I'm parsing the requested scope, compare it to the previously granted scopes, and then pass that object around. For right now I'm just denying the request if the user doesn't accept the full range of scope that the application requested, but eventually I'd like to let the application know which scopes were accepted and which weren't. |
I dug around a bit, figure the call stack out a little better, and made just a few simple changes that I think accomplish everything we both want. |
Here's the diff |
@@ -136,10 +136,12 @@ module.exports = function(server, options, validate, immediate) { | |||
req.oauth2.req = areq; | |||
req.oauth2.user = req[userProperty]; | |||
|
|||
function immediated(err, allow, ares) { | |||
function immediated(err, allow, info) { | |||
req.oauth2.info = info; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems unnecessary. Setting it at txn.info
below should be sufficient. Am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's accessed immediately in the next middleware before deserialization has happened again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How's that? Any next middleware should not be invoked if the response is immediate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the next connect / express middleware is invoked because when the allow is false then the user is directed to the dialog. There I need to be able to access req.oauth2.info
so that I can show the user which scopes were requested so that they can choose to accept them or not.
Trust me, I've tried it both ways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I get that, and that's what setting info on the transaction accomplishes at L167, which will be available in the next middleware at req.oauth2.info
. My issue is with L140, which seems unnecessary. There is no need to set info
when allow is true, because the response is sent immediately and no further middleware gets invoked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting it at L167 doesn't make it available to the next middleware because req.oauth2 !== txn
when the response is deserialized certain keys of txn
are copied to req.oauth2
and when it's serialized certain keys of req.oauth2
is copied to txn
.
I don't think there's any harm in moving the line down into the allow !== true
condition, but it has to exist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha on the serialization bit. Just move this line to L158 then. There may be no harm in setting it in both cases, but I also can't think of a good reason for doing it, so therefore it shouldn't be.
@coolaj86 I merged this (along with some modifications) - the diff can be seen in #110. The only breaking thing I did (relative to your patch) was remove the req.oauth2.info assumption in the decision middleware. If your app expects that, you'll have to pass it from the
I also added support for passing data to the next callback that is not serialized into the transaction. Comments in the diff should explain the intent clearly. Take a look at this and let me know what you think. If all looks good to you, I'll get this up on npm shortly. |
Fix #86 by allowing results of scope checking to pass all the way through to the grant code callback by default.
Also, the callback may inspect the decision request body if needed.