dominik-th / matomo-plugin-LoginOIDC

external authentication services for matomo
https://plugins.matomo.org/LoginOIDC/
GNU General Public License v3.0
42 stars 30 forks source link

Mysqli error after marketplace installation & configuration with keycloak #58

Closed mont5piques closed 2 years ago

mont5piques commented 3 years ago

Hi,

I installed the plugin from matomo marketplace and configured it to connect with my keycloak instance.

After a successful login & redirection, I had this message on matomo redirection page.

Mysqli prepare error: Table 'matomo.matomo_loginoidc_provider' doesn't exist

It seems that the table has not beed created. So I created it manually by looking up the code (I removed the foreign key part which seemed to cause the problem).

tmaex commented 3 years ago

I got the same issue and also created the database myself, but with foreign key. You have to set the proper collate, which isn't set by the install script:

CREATE TABLE <prefix>_loginoidc_provider (
    user VARCHAR( 100 ) NOT NULL,
    provider_user VARCHAR( 255 ) NOT NULL,
    provider VARCHAR( 255 ) NOT NULL,
    date_connected TIMESTAMP NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
    PRIMARY KEY ( provider_user, provider ),
    UNIQUE KEY user_provider ( user, provider ),
    FOREIGN KEY ( user ) REFERENCES <prefix>_user ( login ) ON DELETE CASCADE
) ENGINE=InnoDB **COLLATE utf8mb4_general_ci**;

(adapt for your prefix and collation)

This could be fixed in https://github.com/dominik-th/matomo-plugin-LoginOIDC/blob/4.x-dev/LoginOIDC.php#L175 if you get the correct collation first.

mont5piques commented 3 years ago

Thanks, in my case, I altered the database to add the foreign key but your solution works also.

dominik-th commented 2 years ago

The db table creation has been improved with the latest update, that should fix issues with the engine and/or collation

Aeris1One commented 1 year ago

Hi, I encountered the same error today and when trying @tmaex fix mysql returned ERROR 1071 (42000): Specified key was too long; max key length is 1000 bytes I must admit that I wouldn't be able to dive more into MySQL without instructions, I've only basic knowledge about how it works.