Skip to content

[Security] Feature flags admin endpoint lacks role-based authorization #725

Description

@RUKAYAT-CODER

Overview

src/app/api/admin/feature-flags/route.ts handles GET and POST requests for managing feature flags but does not check whether the requester has an ADMIN role. Any authenticated user (including students) can create, read, and modify feature flags, potentially enabling or disabling functionality across the platform.

Specifications

Features:

  • Feature flag management requires ADMIN role
  • Non-admin authenticated requests return HTTP 403

Tasks:

  • Add requireAuth() at the top of both GET and POST handlers
  • Add if (!hasPermission(user, 'ADMIN')) return forbidden() after authentication
  • Write tests covering student and instructor role attempts returning 403

Impacted Files:

  • src/app/api/admin/feature-flags/route.ts
  • src/app/api/admin/feature-flags/[id]/route.ts
  • src/lib/authMiddleware.ts

Acceptance Criteria

  • GET and POST requests without ADMIN role return HTTP 403
  • Admin-role requests succeed
  • Audit log records the actor for all flag mutations

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions