Skip to content

Wrong column types for user_id and client_id #19

@kschroeer

Description

@kschroeer

I used the script at /data/oauth2.sql to create the database model. Here I find the following table definition:

CREATE TABLE `oauth_access_tokens` (
  ...
  `user_id` int(10) DEFAULT NULL,
  `client_id` int(10) NOT NULL,
  ...
);

The column types are therefore integers, which also makes sense if you want to refer to the IDs of the tables oauth_clients and oauth_users.
But then the following array is assembled in Mezzio\Authentication\OAuth2\Repository\Pdo\AccessTokenRepository:

$params = [
    ':id'         => $accessTokenEntity->getIdentifier(),
    ':user_id'    => $accessTokenEntity->getUserIdentifier(),
    ':client_id'  => $accessTokenEntity->getClient()->getIdentifier(),
    ':scopes'     => $this->scopesToString($accessTokenEntity->getScopes()),
    ':revoked'    => 0,
    ':expires_at' => date(
        'Y-m-d H:i:s',
        $accessTokenEntity->getExpiryDateTime()->getTimestamp()
    ),
];

And here user_id and client_id are returned as a string, which is why the database INSERT subsequently fails and the UniqueTokenIdentifierConstraintViolationException is thrown.

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