Creating new workspaces in Bitnami installations

From pmusers
Jump to: navigation, search

Bitnami installs of ProcessMaker have a bug when creating new workspaces. After setting up a new workspace, the following error will appear when the web browser redirects to the new workspace:

NewUserForWorkspaceCannotLoginToMysqlInBitnami.png

Warning: mysqli_connect(): (HY000/1045): Access denied for user 'wf_5c354f2e66ff1'@'127.0.0.1' (using password: YES) in C:\Bitnami\processmaker-3.3.0-1\apps\processmaker\htdocs\thirdparty\creole\drivers\mysqli\MySQLiConnection.php on line 80
System Exception.
RuntimeException:

 [wrapped: connect failed [Native Error: mysqli_connect(): (HY000/1045): Access denied for user 'wf_5c354f2e66ff1'@'127.0.0.1' (using password: YES)] [User Info: wf_5c354f2e66ff1]]

    At Propel::getConnection()
    in C:\Bitnami\processmaker-3.3.0-1\apps\processmaker\htdocs\workflow\engine\classes\model\om\BasePluginsRegistryPeer.php line 375
    At BasePluginsRegistryPeer::doSelectRS()
    in C:\Bitnami\processmaker-3.3.0-1\apps\processmaker\htdocs\workflow\engine\classes\model\om\BasePluginsRegistryPeer.php line 356
    At BasePluginsRegistryPeer::doSelect()
    in C:\Bitnami\processmaker-3.3.0-1\apps\processmaker\htdocs\workflow\engine\classes\model\PluginsRegistry.php line 28
    At PluginsRegistry::loadPlugins()
    in C:\Bitnami\processmaker-3.3.0-1\apps\processmaker\htdocs\workflow\engine\src\ProcessMaker\Plugins\Traits\PluginStructure.php line 107
    At ProcessMaker\Plugins\PluginRegistry->constructStructure()
    in C:\Bitnami\processmaker-3.3.0-1\apps\processmaker\htdocs\workflow\engine\src\ProcessMaker\Plugins\PluginRegistry.php line 67
    At ProcessMaker\Plugins\PluginRegistry->__construct()
    in C:\Bitnami\processmaker-3.3.0-1\apps\processmaker\htdocs\workflow\engine\src\ProcessMaker\Plugins\PluginRegistry.php line 78
    At ProcessMaker\Plugins\PluginRegistry::loadSingleton()
    in C:\Bitnami\processmaker-3.3.0-1\apps\processmaker\htdocs\workflow\public_html\sysGeneric.php line 701
    At include() in C:\Bitnami\processmaker-3.3.0-1\apps\processmaker\htdocs\workflow\public_html\app.php line 45

The new MySQL user created for the new workspace can't login to MySQL, because the new user has permission to login from the host "localhost", but ProcessMaker is trying to login from the host "127.0.0.1". This problem can be solved either by changing ProcessMaker's db.php file to login from "localhost" or by adding a duplicate user in MySQL that can login from the host "127.0.0.1".

Change ProcessMaker's db.php file

The easier way to fix the problem is to edit the file C:\Bitnami\processmaker-3.X.X-1\apps\processmaker\htdocs\shared\sites\{new_workspace}\db.php with a plain text editor such as Notepad++ and change the host from "127.0.0.1" to "localhost".

For example, if the db.php file contains:

<?php
// Processmaker configuration
  define ('DB_ADAPTER', 'mysql' );
  define ('DB_HOST', '127.0.0.1:3306' );
  define ('DB_NAME', 'wf_test' );
  define ('DB_USER', 'wf_5c3562e4706be' );
  define ('DB_PASS', 'Z7UFh5W9!gPxjGt' );
  define ('DB_RBAC_HOST', '127.0.0.1:3306' );
  define ('DB_RBAC_NAME', 'wf_test' );
  define ('DB_RBAC_USER', 'wf_5c3562e4706be' );
  define ('DB_RBAC_PASS', 'Z7UFh5W9!gPxjGt' );
  define ('DB_REPORT_HOST', '127.0.0.1:3306' );
  define ('DB_REPORT_NAME', 'wf_test' );
  define ('DB_REPORT_USER', 'wf_5c3562e4706be' );
  define ('DB_REPORT_PASS', 'Z7UFh5W9!gPxjGt' );
?>

Then, change it to:

<?php
// Processmaker configuration
  define ('DB_ADAPTER', 'mysql' );
  define ('DB_HOST', 'localhost:3306' );
  define ('DB_NAME', 'wf_test' );
  define ('DB_USER', 'wf_5c3562e4706be' );
  define ('DB_PASS', 'Z7UFh5W9!gPxjGt' );
  define ('DB_RBAC_HOST', 'localhost:3306' );
  define ('DB_RBAC_NAME', 'wf_test' );
  define ('DB_RBAC_USER', 'wf_5c3562e4706be' );
  define ('DB_RBAC_PASS', 'Z7UFh5W9!gPxjGt' );
  define ('DB_REPORT_HOST', 'localhost:3306' );
  define ('DB_REPORT_NAME', 'wf_test' );
  define ('DB_REPORT_USER', 'wf_5c3562e4706be' );
  define ('DB_REPORT_PASS', 'Z7UFh5W9!gPxjGt' );
?>

If the file databases.php exists in the same directory, then edit its contents as well to change the host from "127.0.0.1" to "localhost".

Now, it should be possible to use the new workspace.

Add a duplicate user in MySQL with the host 127.0.0.1

The harder way to fix the problem is to grant the workspace's MySQL user the same permissions when logging in from "127.0.0.1" as "localhost"

1. In order to be able grant permissions to the new workspace's MySQL user, it is necessary to get the password of the "bn_processmaker" user in MySQL, which Bitnami uses in place of a "root" user for security reasons.

Use a plain text editor such as Notepad++ to create the following file:
C:\Bitnami\processmaker-3.X.X-1\apps\processmaker\htdocs\workflow\engine\methods\services\test.php

Add the following content to the test.php file:

<?php
var_dump(@explode(SYSTEM_HASH, G::decrypt(HASH_INSTALLATION, SYSTEM_HASH)));

2. After saving the test.php file, open the web browser. Go to the login screen for the default "workflow" workspace by going to the following address:

http://{your-ip-or-domain}/sysworkflow/en/neoclassic/login/login

Login as the "admin" user (or another user with the PROCESSMAKER_ADMIN role).

LoginAsAdminInWorkflowWorkspace.png

After logging in, then change the address in the web browser to the following URL:

http://{your-ip-or-domain}/sysworkflow/en/neoclassic/services/test

ShowCredentialsOfMysqlSuperuserInWebBrowser.png

The credentials of the MySQL user will be displayed:

  • The host (IP number or domain) from which the user is allowed to connect to workspace's database
  • The username of the MySQL user, which should be "bn_processmaker"
  • The password of the MySQL user

3. Then, open a terminal in Windows to login to MySQL.

Note: A terminal can opened by clicking on the Windows icon in the lower left hand corner of the task bar or by pressing the Windows button, then enter cmd and press ENTER.

Change to the directory where MySQL is installed. For example:

cd C:\Bitnami\processmaker-3.3.0-1\mysql\bin

Then, login to MySQL as the "bn_processmaker" user:

mysql -u bn_processmaker -p

Enter the password that was displayed in the web browser.

After logging into MySQL, then display the list of users by issuing the following command:

mysql>  select User, Host from mysql.user;

Look for a user who has the rights to login from "localhost", but not "127.0.0.1", which is usually the last user in the list. For example:

+------------------+-----------+
| User             | Host      |
+------------------+-----------+
| bn_processmaker  | 127.0.0.1 |
| root             | 127.0.0.1 |
| root             | ::1       |
| bn_processmaker  | localhost |
| root             | localhost |
| wf_5c3562e4706be | localhost |
+------------------+-----------+
8 rows in set (0.00 sec)

Then, display the grants for that user with the command:

show grants for USERNAME@localhost;

For example, if the new workspace is named "test" and the new MySQL user who is created access its database is named "wf_5c3562e4706be":

mysql> show grants for wf_5c3562e4706be@localhost;
+-------------------------------------------------------------------------------------------------------------------------+
| Grants for wf_5c3562e4706be@localhost                                                                                   |
+-------------------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'wf_5c3562e4706be'@'localhost' IDENTIFIED BY PASSWORD '*CB6CC510BC1E132BF5C5C9669223240B8FA44A30' |
| GRANT ALL PRIVILEGES ON `wf_test`.* TO 'wf_5c3562e4706be'@'localhost' WITH GRANT OPTION                                 |
+-------------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

Then copy both GRANT commands and execute them, but change "localhost" to "127.0.0.1" and add ; to the end:

mysql> GRANT USAGE ON *.* TO 'wf_5c3562e4706be'@'127.0.0.1' IDENTIFIED BY PASSWORD '*CB6CC510BC1E132BF5C5C9669223240B8FA44A30';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON `wf_test`.* TO 'wf_5c3562e4706be'@'127.0.0.1' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)

Then, exit MySQL:

mysql> exit;

4. Finally, delete the file C:\Bitnami\processmaker-3.X.X-1\apps\processmaker\htdocs\workflow\engine\methods\services\test.php because it is a security risk.

Now it should be possible to login to the new workspace in ProcessMaker.