Goal
Replace the opaque string-based ApiKeyScope with a closed set of canonical
scope values validated at parse time.
Background
ApiKeyScope::parse(value) currently accepts any non-empty string. This means
invalid scope values can be stored in the database silently, and enforcement code
has no exhaustive list to check against.
Closes part of #46.
Acceptance Criteria
Scope
In scope: rook-core/src/api_key.rs, rook-usecases/src/manage_api_keys.rs
Out of scope: Route-level enforcement (that is Issue 2)
Verification
cargo test -p rook-core
cargo test -p rook-usecases
Goal
Replace the opaque string-based
ApiKeyScopewith a closed set of canonicalscope values validated at parse time.
Background
ApiKeyScope::parse(value)currently accepts any non-empty string. This meansinvalid scope values can be stored in the database silently, and enforcement code
has no exhaustive list to check against.
Closes part of #46.
Acceptance Criteria
KnownScopeenum (or constants) defines the valid scope values:chat:read,chat:write,providers:read,providers:write,adminApiKeyScope::parsereturnsErr(ApiKeyValidationError::UnknownScope)for values not in the canonical set
CreateApiKeyRequestandUpdateApiKeyRequestvalidate scopes beforecalling the repository
(unknown values are preserved but logged as warnings)
Scope
In scope:
rook-core/src/api_key.rs,rook-usecases/src/manage_api_keys.rsOut of scope: Route-level enforcement (that is Issue 2)
Verification