introlab / opentera

OpenTera - Open TeleRehabilitation Server and Micro-Services
https://github.com/introlab/opentera
Apache License 2.0
17 stars 9 forks source link

Keys used for generating tokens are not refreshed in services #238

Open doumdi opened 9 months ago

doumdi commented 9 months ago

Describe the bug Keys are stored in Redis to generate tokens. They are read when each service starts. However, if TeraServer changes the keys, which might happen in test mode when we completely flush the DB and regenerate default values, then the services are not updated with the new keys and calls to API fail with wrong tokens.

To Reproduce Steps to reproduce the behavior:

  1. Launch TeraServer in test mode with --enable_tests=1
  2. Launch other services in test mode
  3. Call the /api/tests/database/reset API to flush an regenerate the default DB
  4. Create a new participant and get its static token
  5. Use the new token to call an endpoint on the service (will be generated with the wrong key from the new DB)

Expected behavior Service must be aware of changes in redis keys and update them in ServiceAccessManager.