dominik-th / matomo-plugin-LoginOIDC

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

Cannot activate LoginOIDC plugin v4.0.0 onto Matomo 4.1.1 with MySQL 5.7 #43

Closed bngrgl closed 1 year ago

bngrgl commented 3 years ago

Hi guys!

Trying to install Login OIDC plugin v4.0.0 onto Matomo 4.1.1 with MySQL 5.7.

Installation passes well, however when I press ACTIVATE PLUGIN button I receive the following error:

There was a problem installing the plugin LoginOIDC:

SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint

If you want to hide this message you must remove the following line under the [Plugins] entry in your 'config/config.ini.php' file to disable this plugin.
Plugins[] = LoginOIDC

If this plugin has already been installed, you must add the following line under the [PluginsInstalled] entry in your 'config/config.ini.php' file:
PluginsInstalled[] = LoginOIDC

Do you have any idea on how we can fix this?

bngrgl commented 3 years ago

Seems that plugin does not support charset utf8mb4 even during the fresh installation. Managed to install it with charset utf8.

ghost commented 3 years ago

Same problem here with MariaDB 10.3

It worked when we 1) set the default character set /collation and 2) set the charset of the login-column in the user table (replace MATOMODB and MATOMOPREFIX):

ALTER DATABASE `MATOMODB`   DEFAULT CHARACTER SET = 'utf8mb4'  DEFAULT COLLATE = 'utf8mb4_general_ci';
ALTER TABLE `MATOMODB`.`MATOMOPREFIX_user` CHANGE COLUMN `login` `login` VARCHAR(100) CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_general_ci' NOT NULL;

Can someone confirm this?

fvdm commented 3 years ago

@DonCarlosGraz I can confirm this is the only way to get the plugin installed.

faust64 commented 3 years ago

Another way to fix this would be to create the <prefix>loginoidc_provider table before enabling the LoginOIDC plugin:

create table matomo_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 matomo_user ( login ) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
dominik-th commented 1 year ago

This should be fixed with the latest update, it uses Matomos DbHelper which should prevent engine/collation issues