Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Rewrited code for python 3, mysql 8 & 5.6, multiple binded apps #46

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

tancou
Copy link

@tancou tancou commented Mar 20, 2020

Hi everyone!

I couldn't manage to run mysqlapi with actual code.
Deps are deprecated, python 2 is deprecated, mysql connector does not work with the latest version 8.

Well, I rewrote some parts in order to make it fresh and easily deployable.

What I've done :

Update to python 3

  • Update deps version
  • Rewrote old syntax from python 2 to python 3
  • Added .python-version file to set python version for tsuru python platform (version 3.7.4)

Update Django

Well, I've done my best to update Django version but I'm not a specialist in Django and some methods deprecated are just removed on the latest version. I didn't consume too much time on it and chosen version 1.6
I added an environment variable MYSQLAPI_DEBUG to disable debug when Django fails to respond to tsuru.

It's now possible to select between mysql 5.6 and mysql 8

  • Added docs to install and set up the chosen version
  • Rewrote mysql queries to match chosen version (when create user and set permission)
  • Default database is now created with utf8mb4_unicode_ci collate
  • Fix foreign key with on_delete=CASCADE

More secure methods

Before, the password of a user was predictable, admin can retrieve it hashing username + SALT. Password should not be retrievable. And if your SALT is leaked (or just blank as default), it's the end of the world for all your app.
Now, it uses a random password. I removed the MYSQLAPI_SALT environment variable.

Allow instance to be bound to multiple apps

The name of the instance (aka database name) was used to define username. So only one user could be created per database.
Now, it uses one user per app bound, with grant all to the instance's database.
Username is created following this pattern : <instance_name>-<app-bound-name>-padding_chars
The first part is truncated to 20 chars, then adds padding characters end up to 32 chars.
Padding characters are calculated with the full name of intance_name and app-bound-name. It prevents username collision with two app-bound-name too long that could be truncated by the limit of 32 characters of mysql.
All hashes are encoded in utf8 (python 3 compatibility).

Updated tsuru.yaml file for easy deploy

The tsuru.yaml file was updated to build the migration.

Update Readme

Better with an updated Readme file.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant