How do I get the UID for the user to later use to set the user when creating nodes and so forth?
// T
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | oauth2_server-2274357-9.patch | 15.09 KB | pjcdawkins |
| #6 | 2274357-6.patch | 13.38 KB | Angry Dan |
How do I get the UID for the user to later use to set the user when creating nodes and so forth?
// T
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | oauth2_server-2274357-9.patch | 15.09 KB | pjcdawkins |
| #6 | 2274357-6.patch | 13.38 KB | Angry Dan |
Comments
Comment #1
bojanz commentedAre you creating the nodes on the server? Or on a client site?
Are you using Services or not?
Which grant type are you using?
Comment #2
timbrandin commentedI am using a Meteor (a Javascript framework) and will be sending through the server side (nodejs).
I used the Authorize grant, or something.
I was able to get the username, but I need the uid when I create nodes through services yes.
Can't the SSO using OAuth2 provide one with both username and uid in the UserInfo?
Thanks for such a quick reply.
// T
Comment #3
bojanz commentedWe need to change the "sub" param to show the uid, not the username (because the username can change, so it isn't stable).
Though to be honest, the fact that you need the uid shows how uncomfortable Services is in this regard... Usually server code just takes the uid of the provided token.
Comment #4
bojanz commentedWe need to do this for the grant types as well.
(The uid is not changeable, but the username is, so it's clear what needs to be used in this context)
Comment #5
Angry Dan commentedI agree that this is major - relying on the username isn't a good practice. I'd suggest a delegate function in the .module file for returning the user_id/sub value for consistency.
Am I right that we just need to replace all output around 'user_id' and 'sub' values? Or is this a more complex change?
Comment #6
Angry Dan commentedOk, I've had a go at implementing this...
I've adjusted the tests to match but I've not run them. I should also stress that I'm not completely familiar with this module yet. Most of my changes appear to be in the Storage class.
Comment #7
pjcdawkins commentedFYI, the tests work. But how do we deal with client sites that already using the username-based sub? I guess the patch does not make it configurable.
Comment #8
pjcdawkins commentedPerhaps this could use
uidby default, but use$user->nameif configured via the module configuration form. An update function should ensure that sites keep the 'name' as the sub, and notify developers should they wish to change it.Comment #9
pjcdawkins commentedThis is #6, re-rolled, with the addition of:
Comment #11
pjcdawkins commentedComment #12
pjcdawkins commentedUnfortunately this breaks OpenID Connect, because the user_id is still the 'sub' in the ID Token, here: https://github.com/bshaffer/oauth2-server-php/blob/master/src/OAuth2/Ope...
Comment #13
pjcdawkins commentedFollowing up in #2467319: Sub property config does not return the right sub in the ID token