Skip to content

Writer role exists in schema but has no functional enforcement #85

@poyrazK

Description

@poyrazK

Why is this an issue?

The database schema allows writer role (internal/adapters/repository/schema.sql:103), and the apikey CLI accepts it (cmd/apikey/main.go:69), but all write operations in the API require RoleAdmin (internal/adapters/api/handler.go:58-63). A key created with role="writer" cannot perform any writes.

What is causing it?

  • Schema allows: CONSTRAINT role_check CHECK (role IN ('admin', 'writer', 'reader'))
  • CLI accepts: if *role != "admin" && *role != "reader" && *role != "writer"
  • But handler.go only checks for RoleAdmin on write operations

How can it be solved?

Either:

  1. Implement writer role (add RoleWriter = "writer" to domain/auth.go and update RequireRole checks)
  2. Remove writer role from schema and CLI if it won't be implemented

Category

  • Small
  • Medium
  • Large

Severity

  • Low
  • Medium
  • High
  • Critical

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions