oAuth and User attribute json path
rycks opened this issue · comments
Hello,
how could i map OM User attribute and OAuth User attribute when oAuth json is like that (from nextcloud):
{
"ocs": {
"meta": {
"status": "ok",
"statuscode": 200,
"message": "OK"
},
"data": {
"storageLocation": "xxxxx",
"id": "xxxxx",
"lastLogin": 1584799957000,
"backend": "Database",
"subadmin": [],
"quota": {
"free": 183035547648,
"used": 10244,
"total": 183035557892,
"relative": 0,
"quota": -3
},
"email": "xxxxxx",
"phone": "",
"address": "",
"website": "",
"twitter": "",
"groups": [
"xxxxxx"
],
"language": "en",
"locale": "",
"backendCapabilities": {
"setDisplayName": true,
"setPassword": true
},
"display-name": "xxxxx"
}
}
}
i've tried address.email = ocs.data.email but it does not work, here is the error log
DEBUG 03-21 16:26:22.533 o.a.o.w.p.a.SignInPage:292 [nio-5080-exec-9] - User info={"ocs":{"meta":{"status":"ok","statuscode":200,"message":"OK"},"data":{"storageLocation":"xxxxx","id":"xxxxxxx","lastLogin":1584799957000,"backend":"Database","subadmin":[],"quota":{"free":183034261504,"used":10244,"total":183034271748,"relative":0,"quota":-3},"email":"xxxxxxx","phone":"","address":"","website":"","twitter":"","groups":["xxxxxxx"],"language":"en","locale":"","backendCapabilities":{"setDisplayName":true,"setPassword":true},"display-name":"xxxxxxx"}}}
ERROR 03-21 16:26:22.534 o.a.o.d.d.u.OAuthUser:65 [nio-5080-exec-9] - Failed to get user email from JSON: {}
ERROR 03-21 16:26:22.534 o.a.o.w.a.UserManager:235 [nio-5080-exec-9] - Invalid login, please check parameters
ERROR 03-21 16:26:22.534 o.a.o.w.p.a.SignInPage:303 [nio-5080-exec-9] - Failed to login via OAuth2!
Thanks
Hello @rycks,
According to the code OM checks login
mapping, and selects sub-object based on this
here is the test illustrating this https://github.com/apache/openmeetings/blob/master/openmeetings-db/src/test/java/org/apache/openmeetings/db/dto/user/TestOAuthUser.java#L85
I guess in your case you need to create mapping login
-> email
in this case ocs.data
should be selected as User JSON
please let me know if it will work
I'll do additional tests if not
Hello @solomax
i'm sorry but it does not ... and if i hack nextcloud to return a "flat" json array like that it works so it seems to be a sort of "access path" problem ...
{
"status": "ok",
"statuscode": 200,
"message": "OK",
"storageLocation": "xxxxx",
"id": "xxxxx",
"lastLogin": 1584799957000,
"backend": "Database",
"subadmin": [],
"free": 183035547648,
"used": 10244,
"total": 183035557892,
"relative": 0,
"quota": -3,
"email": "xxxxxx",
"phone": "",
"address": "",
"website": "",
"twitter": "",
"groups": [
"xxxxxx"
],
"language": "en",
"locale": "",
"display-name": "xxxxx"
}
OK,
I'll use your original JSON and will write some tests :)
I see the issue
Only one level is being checked ...
will try to fix
Should be fixed
Please check latest SNAPSHOT
https://builds.apache.org/view/M-R/view/OpenMeetings/job/openmeetings/
3053+
PERFECT !!!! THANKS A LOT !