auth0 / go-auth0

Go SDK for the Auth0 Management API.
https://auth0.com
MIT License
135 stars 54 forks source link

User struct is missing additional identity provider details #199

Closed nzoschke closed 1 year ago

nzoschke commented 1 year ago

Checklist

Description

Using the Management API explorer, I see that the GET /users/:id API returns the user profile with extra details from an identity provider that matches the "Raw JSON" in the user management UI.

However using the Go client, the User struct doesn't have a place to unmarshal these extra details.

https://github.com/auth0/go-auth0/issues/34 is possibly related, but in this API the extra details are on the top level response, not under user.identities.

Perhaps the User struct could have one more field with the complete API response in a map[string]interface{} ?

Expectation

When the User Raw JSON is like

{
    "active": true,
    "created_at": "2023-04-26T20:57:04.053Z",
    "email": "user@example.com",
    "email_verified": true,
    "family_name": "Example",
    "given_name": "User",
    "id": "https://login.salesforce.com/id/00D46000001EXAMPLE/0054o000002EXAMPLE",
    "identities": [
        {
            "provider": "salesforce",
            "user_id": "0054o000002EXAMPLE",
            "connection": "salesforce",
            "isSocial": true
        }
    ],
    "is_lightning_login_user": false,
    "language": "en_US",
    "last_modified_date": "2023-04-11T17:17:47Z",
    "locale": "en_US",
    "mobile_phone_verified": false,
    "name": "User Example",
    "nickname": "User",
    "organization_id": "00D46000001EXAMPLE",
    "picture": "https://example.file.force.com/profilephoto/005/F",
    "picture_thumbnail": "https://example.file.force.com/profilephoto/005/T",
    "status": {
        "created_date": null,
        "body": null
    },
    "timezone": "America/Phoenix",
    "updated_at": "2023-04-27T16:15:25.526Z",
    "urls": {
        "enterprise": "https://example.my.salesforce.com/services/Soap/c/{version}/00D46000EXAMPLE",
        "metadata": "https://example.my.salesforce.com/services/Soap/m/{version}/00D46000EXAMPLE",
        "partner": "https://example.my.salesforce.com/services/Soap/u/{version}/00D46000EXAMPLE",
        "rest": "https://example.my.salesforce.com/services/data/v{version}/",
        "sobjects": "https://example.my.salesforce.com/services/data/v{version}/sobjects/",
        "search": "https://example.my.salesforce.com/services/data/v{version}/search/",
        "query": "https://example.my.salesforce.com/services/data/v{version}/query/",
        "recent": "https://example.my.salesforce.com/services/data/v{version}/recent/",
        "tooling_soap": "https://example.my.salesforce.com/services/Soap/T/{version}/00D46000EXAMPLE",
        "tooling_rest": "https://example.my.salesforce.com/services/data/v{version}/tooling/",
        "profile": "https://example.my.salesforce.com/0054o000002EXAMPLE",
        "feeds": "https://example.my.salesforce.com/services/data/v{version}/chatter/feeds",
        "groups": "https://example.my.salesforce.com/services/data/v{version}/chatter/groups",
        "users": "https://example.my.salesforce.com/services/data/v{version}/chatter/users",
        "feed_items": "https://example.my.salesforce.com/services/data/v{version}/chatter/feed-items",
        "feed_elements": "https://example.my.salesforce.com/services/data/v{version}/chatter/feed-elements",
        "custom_domain": "https://example.my.salesforce.com"
    },
    "user_id": "salesforce|0054o000002EXAMPLE",
    "user_type": "STANDARD",
    "username": "user@example.com",
    "utcOffset": -25200000,
    "last_ip": "2600:1700:9da3:c850:d424:b148:1f01:46d8",
    "last_login": "2023-04-27T16:15:25.522Z",
    "logins_count": 33,
    "blocked_for": [],
    "guardian_authenticators": []
}

A call to auth0.User.Read(profile.ID) will allow a client to get additional identity provider details like organization_id 00D46000001EXAMPLE

Reproduction

  1. Register or log in with a Salesforce connection
  2. See Salesforce identity provider data like organization_id 00D46000001EXAMPLE in API response from GET /users/:id call
  3. See no Salesforce identity provider data in the User struct from auth0.User.Read(profile.ID) call

Auth0 Go SDK version

main

ewanharris commented 1 year ago

Hey @nzoschke šŸ‘‹šŸ»

The user struct in go-auth0 only contains the properties supported by Auth0, our suggestion for supporting custom properties from an IDP is to provide a custom User struct as shown here.

Please let me know if you have any questions.

nzoschke commented 1 year ago

Ok thank you! Missed that in the docs.