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 forGETandPUToperations 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
Configstruct: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
setupRoutesfunction to conditionally apply theauthMiddlewareto thegetKVHandlerandputKVHandlerbased on these configuration flags.AllowAnonymousReadisfalse, applyauthMiddlewarewith a "read" scope requirement togetKVHandler.AllowAnonymousWriteisfalse, applyauthMiddlewarewith a "write" scope requirement toputKVHandler.deleteKVHandlershould 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:
Configstruct for new fields.setupRoutesfunction to apply middleware conditionally.getKVHandler,putKVHandler,deleteKVHandlerfunctions.authMiddlewarefunction.