Skip to content

Allow "sub" as second option (to "id") for the ressource owner user id #1074

@Jefferson49

Description

@Jefferson49

The current implementation of the generic oauth2-client, expects the ressource owner to have an "id":
https://github.com/thephpleague/oauth2-client/blob/master/src/Provider/GenericProvider.php#L79

If the response with the user data from the authorization server does not have an "id", the following code will throw a PHP error:
https://github.com/thephpleague/oauth2-client/blob/master/src/Provider/GenericResourceOwner.php#L49

However, many OpenID Connect implementations, return "sub" as user ID. Since the "sub" claim is the typical unique identifier for the end-user in Open ID Connect, I propose to allow "sub" as a second option in function getId(); getId could check for "id" first, and check "sub" in a second step.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions