conwetlab / ckanext-oauth2

OAuth2 support for CKAN
GNU Affero General Public License v3.0
25 stars 56 forks source link

Support profiles with nested fields #34

Open frafra opened 5 years ago

frafra commented 5 years ago

Hi, some providers do not reply with a flat JSON; for example, dataporten.no has a /userinfo endpoint where the user's details are stored under user:

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
    "user": {
        "userid": "...",
        "userid_sec": ["feide:..."],
        "name": "...",
        "email": "...",
        "profilephoto": "p:..."
    },
    "audience": "..."
}

Source: https://docs.feide.no/developer_oauth/technical_details/oauth_authentication.html

The user_json function assumes a flat JSON instead:

https://github.com/conwetlab/ckanext-oauth2/blob/e68dd2664229b7563d77b2c8fc869fe57b747c88/ckanext/oauth2/oauth2.py#L173-L175

I made a workaround for that, but it is not a generic fix: https://github.com/NINAnor/ckanext-oauth2/commit/f86448f5cb0c30b981ea59bec5090112a4553e76

frafra commented 2 years ago

Any feedback on that?