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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
.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
utf8mb4_unicode_ci
collateon_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 deployThe
tsuru.yaml
file was updated to build the migration.Update Readme
Better with an updated Readme file.