pyramid_oauth2_provider icon indicating copy to clipboard operation
pyramid_oauth2_provider copied to clipboard

Mysql dialect Support

Open tonthon opened this issue 7 years ago • 4 comments

The Oauth2Client model use the following definition

    _client_secret = Column(Binary(255), unique=True, nullable=False)

On db initialization, the following error is raised

OperationalError: (_mysql_exceptions.OperationalError) (1170, "BLOB/TEXT column '_client_secret' used in key specification without a key length") [SQL: u'\nCREATE TABLE oidc_client (\n\tid INTEGER NOT NULL AUTO_INCREMENT, \n\tclient_id VARCHAR(64) NOT NULL, \n\t_client_secret BLOB(255) NOT NULL, \n\trevoked BOOL, \n\trevocation_date DATETIME, \n\tCONSTRAINT pk_oidc_client PRIMARY KEY (id), \n\tCONSTRAINT test UNIQUE (_client_secret), \n\tCONSTRAINT uq_oidc_client_client_id UNIQUE (client_id), \n\tCONSTRAINT ck_oidc_client_revoked CHECK (revoked IN (0, 1))\n)ENGINE=InnoDB CHARSET=utf8\n\n']

setting the column type to sqlalchemy.dialects.mysql.BINARY works as expected (but it's not a satisfying solution).

tonthon avatar Mar 29 '17 16:03 tonthon

I believe I need to remove unique=True on this, which won't be a problem for this column. Will work on this later today.

secynic avatar Mar 29 '17 17:03 secynic

Removing unique=true from the column worked in my tests. Please try on your end, and I will submit a PR for it.

Just for reference...this is ok to remove since it is an encrypted field, and a password tied to a unique client_id, so uniqueness does not matter.

The issue was related to MySQL limitation on indexing size.

secynic avatar Mar 30 '17 00:03 secynic

Yes it's an indexing problem, removing it should do the trick

tonthon avatar Mar 30 '17 14:03 tonthon

@elliotpeele Any update on merging #21?

secynic avatar May 31 '17 02:05 secynic