Skip to content

Conversation

@adskyiproger
Copy link
Contributor

@adskyiproger adskyiproger commented Sep 19, 2025

Description

Postgres admin permissions are mixed with analytics user. Goal of this PR is to separate permissions:

  • Postgres admin remain responsible for:
    • backup
    • restore
    • migration
  • analytics user will be responsible for it's own stuff in countryconfig

Test results

Environment is available at: https://fix-analytics.opencrvs.dev/

Checklist

  • I have linked the correct Github issue under "Development"
  • I have tested the changes locally, and written appropriate tests
  • I have tested beyond the happy path (e.g. edge cases, failure paths)
  • I have updated the changelog with this change (if applicable)
  • I have updated the GitHub issue status accordingly

jamil314 and others added 30 commits August 28, 2025 14:22
feat: Trigger notification for events
e2e testing: Notification API requires 'createdAtLocation'
jamil314 and others added 20 commits September 18, 2025 15:34
…ials' into use-postgres-superuser-credentials
@github-actions

This comment has been minimized.

Copy link
Contributor

@Zangetsu101 Zangetsu101 left a comment

Choose a reason for hiding this comment

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

I think we are still using ANALYTICS_POSTGRES_USER in some of the compose files, which should be removed if we are gonna generate the username. As during the deploy, it errors if the ANALYTICS_POSTGRES_USER is not present in the github environment currently

export EVENTS_APP_POSTGRES_PASSWORD=`generate_password`
export EVENTS_MIGRATOR_POSTGRES_PASSWORD=`generate_password`
export ANALYTICS_POSTGRES_PASSWORD=`generate_password`
export ANALYTICS_POSTGRES_USER=`generate_password`
Copy link
Contributor

Choose a reason for hiding this comment

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

So user name is also rotated?

Copy link
Member

@naftis naftis Sep 19, 2025

Choose a reason for hiding this comment

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

To be honest, I don't know what is generally the convention. In our codebase we sometimes rotate usernames but for Postgres we haven't yet? Feel free to do like you wish.

May help with onboarding if they don't need to decide username for this?

❗ I don't think setup-analytics.sh supports altering usernames

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right and static user name will work better,
I did tested data seed, deploy, but just imagine situation when you do rotation every time on real environment?

What will happen after 10 sequential deployments?
10 different users with same privileges

I will drop this line, but where should we store analytics user name?

We are using hardcoded user name for events app and migrator

Copy link
Member

@naftis naftis Sep 19, 2025

Choose a reason for hiding this comment

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

The roles are altered on setup-analytics.sh, no new ones should be created. So that's fine?

Initially I did write the setup-analytics.sh with events_analytics username to keep up with the convention. I'm not sure why Riku changed it to a variable, maybe to help with the same issue why we now replace the variables in core .sql files?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Kept events_analytics user name for consistency with events_app and events_migratior

@adskyiproger adskyiproger merged commit 225111f into develop Sep 19, 2025
5 of 6 checks passed
@adskyiproger adskyiproger deleted the fix-analytics-user branch September 19, 2025 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.