Skip to content

getClient called with non-decoded secret/client #213

Closed
@MaximilianGaedig

Description

@MaximilianGaedig

Here getClientCredentials takes request.body.client_id and request.body.client_secret without calling decodeURIComponent() on them:

// token-handler.js
TokenHandler.prototype.getClientCredentials = function(request) {
  [...]
  if (request.body.client_id && request.body.client_secret) {
    return { clientId: request.body.client_id, clientSecret: request.body.client_secret };
  }
 [...]
};

The result of this is not the client secret arriving at the getClient method, but the url encoded version of it, which in my case was base64 encoded so it was changed and the getClient method failed.

I think handling it in the model is not problematic but unnecessary so it should be done in the library

"Workaround"

class Model {
  async getClient(clientId: string, clientSecret: string | null): Promise<Client | Falsey> {
    const clientIdDecoded = decodeURIComponent(clientId);
    const clientSecretDecoded = clientSecret ? decodeURIComponent(clientSecret) : null;
    // use clientIdDecoded and clientSecretDecoded in your database logic instead of clientId and clientSecret
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussion 🗨️Discussion about a particular topic.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions