Two front doors: Module-level ... Note
GitLab

Two front doors: Module-level access in a Django GRC app

GitLab's internal GRC tool faced an authorization challenge with its dual customer base: Security Compliance and Internal Audit. Initially designed for one team, it lacked robust authorization to prevent one group from accessing the other's sensitive data. The login_required decorator only confirmed login status, not specific permissions. This oversight became critical when the Internal Audit team needed the tool for their own distinct workflow and data.To address this, GitLab restructured the application into a core Django project and two independent module apps. The core handles shared functionalities like authentication and user management. Each module, for Security Compliance and Internal Audit respectively, manages its own models, views, and APIs. Crucially, the core has no knowledge of the specific data within each module, ensuring clean separation.Access control was implemented using Django's built-in authentication system, mapping each module to a specific group. Users can belong to one or both groups, and this membership dictates their access. This separation of duty is enforced at the UI, view, and API layers.A reusable GroupRequiredMixin in the core app checks group membership for module-specific subclasses. This minimal cost allows for consistent enforcement across modules. A template filter, user_in_group, also enhances the user experience by hiding navigation elements a user isn't authorized to see. This UI guard complements the stricter enforcement at the view and API levels.This architectural decision creates a repeatable, team-agnostic pattern for future modules. New workflows can inherit the existing access control structure, audit trail, and authentication, significantly reducing infrastructure overhead. The process begins by identifying the authorization gap in existing views and then defining module boundaries before coding. Implementing a single, subclassable mixin in the core and enforcing permissions at all layers are key steps.