Add Configuration for Anonymous Read and Write Access to KV Endpoints #5
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Currently, the
/kv/{path}
endpoints forGET
andPUT
operations are publicly accessible without any authentication. While this might be desired in some scenarios for a simple key-value store, it lacks the flexibility to secure these core data access points. Many deployments will require all data access to be authenticated and authorized.Proposed Solution:
Introduce two new configuration parameters in the
Config
struct:AllowAnonymousRead
(boolean, defaultfalse
): Iftrue
,GET /kv/{path}
requests will not require authentication.AllowAnonymousWrite
(boolean, defaultfalse
): Iftrue
,PUT /kv/{path}
requests will not require authentication.Modify the
setupRoutes
function to conditionally apply theauthMiddleware
to thegetKVHandler
andputKVHandler
based on these configuration flags.AllowAnonymousRead
isfalse
, applyauthMiddleware
with a "read" scope requirement togetKVHandler
.AllowAnonymousWrite
isfalse
, applyauthMiddleware
with a "write" scope requirement toputKVHandler
.deleteKVHandler
should always require authentication and appropriate scopes (e.g., "delete").This provides granular control over public access to the core key-value store functionality.
Relevant Code Sections:
Config
struct for new fields.setupRoutes
function to apply middleware conditionally.getKVHandler
,putKVHandler
,deleteKVHandler
functions.authMiddleware
function.