Closed jason-fox closed 1 year ago
Hi @jason-fox
Do you mean editing the section in the readthedocs docu to include differences with the previous release and how should proceed to update release (e.g. running "npm run migrate_db")?
Precisely - this is just missing documentation.
Even better would be to keep a backup.sql
file within the repo (generated by the seeding task) and users could use that to check the differences. In the case described above, it would be easier just to delete tokens of course, but it would be nice to be forewarned in the release notes or somewhere if/when database changes occur. The advantage of creating a file in the repo is that the history and diff are always correctly maintained.
Wasn't the migration done automatically when the flag IDM_DB_SEED is set? At least I think it was doing it in the past. But when moving to 8.0.0 now, I had to run the "npm run migrate_db" manually.
IDM_DB_SEED
is not set within the FIWARE Tutorials since they already have a pre-seeded database with users and OAuth tokens and applications and so on. The Tutorials are released as part of each FIWARE release and always use the latest FIWARE Components so it makes sense to pre-seed a Keyrock 8.0 tutorial with 8.0 database tables.
I think IDM_DB_SEED
just seeds if the DB is not found anyway - it should be considered as a security flaw if the system could add a backdoor superuser with a known username and password to an already running system - this is why migration 7.X => 8.X should be detailed in the release note.
I see this as a duplicated of #188. Database migrations are already shipped with KeyRock, so you are not required to do anything by hand regarding upgrading the database but executing the npm run migrate_db
command. Documenting how to run this command in a safe way (e.g. doing backups) and so on ... would solve this issue.
Maybe, a new flag (disabled by default) for enabling automigration at container start can be useful for simple scenarios where just a single container of KeyRock is used connected to a single database and better if the instance not used for production. Something like:
Although migrations should not provide high risk of creating security problems: migrations are provided by the image (so they are official migrations and they are not programmed for changing the credentials of the super user); they can introduce security problems through bugs in the migration implementation and, also, they can provide some kind of data corruption. So I think they should be done using a maintenance procedure (database backup, running sanity check after applying the migrations, ...) that's the reason I don't recommend to enable them by default.
Thanks for the useful comments. I agree with you Jason that it makes sense to keep a backup file. Could one of the backup files from the tutorials be used? I will edit the documentation to include a section with changes on every release also. I will also take a look at PR 217 about the @aarranz suggestion.
I created this SQL from release 8.0: https://github.com/FIWARE/tutorials.Identity-Management/blob/master/mysql-data/backup.sql using the docker exec db-mysql /usr/bin/mysqldump -u root --password=secret idm > mine.sql
technique - it should hold the data from the 8.0 seed.
Not much use on its own, but as the database changes over time it could prove more useful than deciphering all the incremental sequelize patch statements.
Stale
Related to https://github.com/ging/fiware-idm/issues/188
On upgrading Keyrock existing users cannot access the IDM. There is no help or documentation to help users to do so.
Usually the technique described in #188 is sufficient (although it would be better if a diff could be supplied in the docs, but 8.0.0 also brings a breaking change in the
oauth_access_token
table:The
hash
column is now mandatory and holds data derived from the user's account. I wrote a simple script to work out the hashes, but ideally a proper sequelize function should be provided instead:Which results in the following SQL: