OpenID-Connect-PHP icon indicating copy to clipboard operation
OpenID-Connect-PHP copied to clipboard

Clarification needed for addScope method: Avoid duplicate "openid" scope

Open LaurentNoyon opened this issue 6 months ago • 1 comments

Problem:

I encountered an issue with the addScope method when using it to add scopes to an OpenID connection. I think that the current implementation of addScope lacks of clarity around the fact that the "openid" scope is already included by default.

In my case I unintentionally duplicated the "openid" scope by calling addScope(["openid"]), which resulted in the "openid" scope being duplicated in the final list of scopes.

Code incriminated :

if (count($this->scopes) > 0) {
    $auth_params = array_merge($auth_params, ['scope' => implode(' ', array_merge($this->scopes, ['openid']))]);
}

Suggestions:

  • Warning message: Implement a warning message that informs developers when they attempt to add the "openid" scope, indicating that this scope is already included by default.

  • Automatic handling: Alternatively, the addScope method could automatically ignore the addition of the "openid" scope via addScope method, thus preventing duplication.

Thank you for considering this enhancement.

LaurentNoyon avatar Aug 09 '24 09:08 LaurentNoyon