Skip to content

Candidats : Historisation des changements de l'ID unique envoyé à l'ASP#5911

Merged
rsebille merged 3 commits into
masterfrom
rsebille/job-seeker-profile-asp-uid-history
Apr 9, 2025
Merged

Candidats : Historisation des changements de l'ID unique envoyé à l'ASP#5911
rsebille merged 3 commits into
masterfrom
rsebille/job-seeker-profile-asp-uid-history

Conversation

@rsebille

@rsebille rsebille commented Apr 8, 2025

Copy link
Copy Markdown
Contributor

🤔 Pourquoi ?

La génération de asp_uid utilise django.crypto.utils.salted_hmac() qui si aucun secrets n'est passé en paramètre utilise settings.SECRET_KEY, celui-ci a été changé il y a peu donc on se retrouve avec le message d'erreur "Valeur initiale : ..." pour tout les profils candidats ayant été crée avant ce changement.

🍰 Comment ?

  • Historisation de la modification du champ avec notre trigger maison FieldsHistory()
  • Script pour ajouter un élément au champ d'historique quand la valeur actuelle de asp_uid n'est pas celles attendues
  • Suppression de la mention "Valeur initiale : ..." maintenant que nous avons un historique complet

@rsebille rsebille added the ajouté Ajouté dans le changelog. label Apr 8, 2025
@rsebille
rsebille requested review from tonial and xavfernandez April 8, 2025 08:04
@rsebille rsebille self-assigned this Apr 8, 2025
@rsebille
rsebille force-pushed the rsebille/job-seeker-profile-asp-uid-history branch from 3bf821f to ad429f6 Compare April 8, 2025 08:17
Comment thread itou/scripts/management/commands/fill_job_seeker_profile_asp_uid_changes.py Outdated
print(f"> Change to {profile.asp_uid=} was already logged")
continue

with transaction.atomic(), pgtrigger.ignore("users.JobSeekerProfile:job_seeker_profile_fields_history"):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

propre ce context manager 👍

Comment thread itou/scripts/management/commands/fill_job_seeker_profile_asp_uid_changes.py Outdated
@tonial

tonial commented Apr 9, 2025

Copy link
Copy Markdown
Contributor

Mince, je suis désolé de cet effet de bord 😱

rsebille added 3 commits April 9, 2025 11:10
Now that we have `fields_history` on `JobSeekerProfile()` we want to
track changes that have already happened, the now is not really
important, but the values are!
Since `SECRET_KEY` was change only newly created `JobSeekerProfile()`
will not display the message, but now that we are tracking field changes
and added previous changes we can remove this.
@rsebille
rsebille force-pushed the rsebille/job-seeker-profile-asp-uid-history branch from ad429f6 to 19433bf Compare April 9, 2025 09:10
@rsebille

rsebille commented Apr 9, 2025

Copy link
Copy Markdown
Contributor Author

Mince, je suis désolé de cet effet de bord 😱

Ça a eu l'avantage de nous apprendre un truc, et de révéler une faiblesse du système, c'est win-win 👍.

@rsebille
rsebille requested a review from xavfernandez April 9, 2025 09:28
super().add_arguments(parser)

parser.add_argument("--old-secret", dest="old_secret", required=True, type=str)
parser.add_argument("--new-secret", dest="new_secret", required=True, type=str)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tu pourrais éventuellement éviter de passer le secret en ligne de commande et aller lire directement setting.SECRET_KEY ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je voulais effectivement faire ça, mais en local SECRET_KEY est forcé à foobar dans la conf de test (et donc de dev), et je voulais pas avoir à tout redéclarer en utilisant la conf de base.
Mais je n'ai pas prévu de copier coller les secrets dans la ligne de commande, je vais sûrement passer par un source mon-fichier.env && --old-secret "${OLD_DJANGO_SECRET_KEY}" --new-secret "${DJANGO_SECRET_KEY}"

@rsebille
rsebille added this pull request to the merge queue Apr 9, 2025
Merged via the queue into master with commit 154ee37 Apr 9, 2025
@rsebille
rsebille deleted the rsebille/job-seeker-profile-asp-uid-history branch April 9, 2025 13:36
@sentry

sentry Bot commented Apr 9, 2025

Copy link
Copy Markdown

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ KeyboardInterrupt itou.scripts.management.commands.fill_job_seeke... View Issue

Did you find this useful? React with a 👍 or 👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ajouté Ajouté dans le changelog.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants