Skip to content

Conversation

@Rotheem
Copy link
Member

@Rotheem Rotheem commented Feb 27, 2025

Description

Summary

Introducing permissions

Relying on hardcoded groups for access restriction is prone to be limiting at some point. We can't easily change which group owns a specific module and it is heavily dependent on Centrale's association structure.

This PR introduces a new concept : Permissions. Represented by system-wide unique string they are declared by modules and replace completely GroupTypes for endpoint restriction. A user must have the endpoint's specific permission to have access to it. A permission can be linked to a user through 2 ways :

  • Linking a group to the permission and having the user in the group
  • Linking an account type to the permission and having this account type for the user

Thus, a permission can be linked to multiple groups and/or account type, can be easily transferred and allow each Hyperion instance to adapt better to any school's association structure.

Improving visibility

The visibility system was introduced to restrict in-app access to module, however it was still falling short for direct API calls both in synchronization and flexibility. The visibility could be set on/off for certain account types or groups while the endpoint would still be restricting another group and only GroupType could be used for API restriction.

To address this issue, we use access_XXX permissions, this specific syntax will be recognized by Titan as a replacement for visibility. As permissions are fully modular and uniformized, both issues are resolved by replacing visibility by specific permissions.

Integrating auth restriction

Auth providers allow access depending on account types or GroupTypes, however as permissions delete GroupTypes there was a need to refacto this part. The chosen method is a set of specific permissions for auth manually added to the global permission list after the module discovery.

Changes Made

  • add permissions modification logic
  • declare modules' permissions
  • refactor all modules' endpoints restrictions with permissions check
  • refactor visibility with specific permissions
  • refactor auth access

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)

  • ✨ New feature (non-breaking change which adds functionality)

  • 🔨 Refactor (non-breaking change that neither fixes a bug nor adds a feature)

  • 🔧 Infra CI/CD (changes to configs of workflows)

  • 💥 BREAKING CHANGE (fix or feature that require a new minimal version of the front-end)

  • 😶‍🌫️ No impact for the end-users

Impact & Scope

  • Core functionality changes

  • Single module changes

  • Multiple modules changes

  • Database migrations required

  • Other:

Testing

  • 1. Tested this locally

  • 2. Added/modified tests that pass the CI

  • 3. Tested in a pre-prod

  • 0. Untestable (exceptionally), will be tested in prod directly

Documentation

  • Updated the docs accordingly :

  • " Docstrings

  • # Inline comments

  • No documentation needed

@armanddidierjean armanddidierjean changed the base branch from main to core-refacto February 27, 2025 07:28
@armanddidierjean armanddidierjean changed the base branch from core-refacto to main February 27, 2025 07:29
@Rotheem Rotheem force-pushed the modular-permissions branch from e838be1 to d2c5224 Compare February 27, 2025 16:15
@codecov
Copy link

codecov bot commented Oct 26, 2025

Codecov Report

❌ Patch coverage is 89.29504% with 41 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.85%. Comparing base (f5d2f74) to head (3ea1284).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
app/core/permissions/endpoints_permissions.py 80.35% 11 Missing ⚠️
app/core/permissions/cruds_permissions.py 78.26% 10 Missing ⚠️
app/app.py 63.15% 7 Missing ⚠️
app/module.py 66.66% 6 Missing ⚠️
app/dependencies.py 93.33% 1 Missing ⚠️
app/modules/calendar/endpoints_calendar.py 88.88% 1 Missing ⚠️
app/modules/campaign/cruds_campaign.py 0.00% 1 Missing ⚠️
app/modules/phonebook/endpoints_phonebook.py 80.00% 1 Missing ⚠️
app/modules/raffle/endpoints_raffle.py 87.50% 1 Missing ⚠️
app/utils/initialization.py 88.88% 1 Missing ⚠️
... and 1 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #679      +/-   ##
==========================================
+ Coverage   84.84%   84.85%   +0.01%     
==========================================
  Files         193      200       +7     
  Lines       13889    14075     +186     
==========================================
+ Hits        11784    11944     +160     
- Misses       2105     2131      +26     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@NakoGH NakoGH force-pushed the modular-permissions branch from f36789e to c0d357a Compare November 20, 2025 13:20
Rotheem added 13 commits January 1, 2026 22:21
^ Conflicts:
^	app/core/groups/groups_type.py
^	app/core/memberships/endpoints_memberships.py
^	app/dependencies.py
^	app/module.py
^	app/modules/cdr/coredata_cdr.py
^	app/modules/cdr/dependencies_cdr.py
^	app/modules/cdr/endpoints_cdr.py
^	app/modules/cdr/utils_cdr.py
^	app/modules/centralassociation/endpoints_centralassociation.py
^	app/modules/raid/endpoints_raid.py
^	app/modules/sport_competition/dependencies_sport_competition.py
^	app/modules/sport_competition/endpoints_sport_competition.py
^	app/modules/sport_competition/utils/schemas_converters.py
^	app/modules/sport_competition/utils_sport_competition.py
^	app/utils/auth/providers.py
^	tests/config.test.yaml
^	tests/core/test_core.py
^	tests/core/test_memberships.py
^	tests/modules/cdr/test_cdr.py
^	tests/modules/sport_competition/test_purchases.py
^	tests/modules/sport_competition/test_sport_inscription.py
^	tests/modules/sport_competition/test_validation.py
^	tests/modules/test_flappybird.py
^	tests/modules/test_raid.py
@Rotheem Rotheem force-pushed the modular-permissions branch from c57eba9 to b585845 Compare January 1, 2026 21:21
@Rotheem Rotheem merged commit a540c36 into main Jan 2, 2026
7 checks passed
@Rotheem Rotheem deleted the modular-permissions branch January 2, 2026 01:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants