BeiBaiNian opened a new pull request, #183:
URL: https://github.com/apache/casbin-gateway/pull/183

   
   # Why
   
   - CasWAF is being transformed into a UI-first LLM API security gateway 
(issue #179). The gateway needs a place where users can configure upstream LLM 
services (e.g. OpenAI, DeepSeek, Anthropic) before the unified entry 
(/v1/chat/completions), token authentication, rate limiting and logging can be 
built on top.
   - Subtask 1.1 introduces the Channel entity — one upstream LLM service 
configuration (base URL, secret key, supported models, status) — with a data 
model and a full CRUD API, following the existing object/site.go pattern in 
this repo.
   - This is the foundation for the following subtasks: routing (1.2), token 
authentication (1.3), logs (1.4) and the frontend pages (1.5).
   
   # What changed
   
   - object/channel.go (new): Channel data model (owner/name composite primary 
key, timestamps, type, baseUrl, secretKey, models, status) and CRUD functions: 
GetGlobalChannels, GetChannels, GetChannel, AddChannel, UpdateChannel, 
DeleteChannel, plus pagination helpers GetChannelCount / GetPaginationChannels.
   - Secret key masking: GetMaskedChannel / GetMaskedChannels mask the secret 
key (e.g. sk-a****-777) before returning it to the frontend, following the 
existing GetMaskedSite pattern.
   - Update safety: UpdateChannel skips the secret_key column when the incoming 
value is empty or masked (contains ****), so a masked value returned by the 
frontend can never overwrite the real key in the database.
   - controllers/channel.go (new): six API handler methods (GetGlobalChannels, 
GetChannels, GetChannel, AddChannel, UpdateChannel, DeleteChannel), each 
guarded by RequireSignedIn().
   - routers/router.go: register six routes: /api/get-global-channels, 
/api/get-channels, /api/get-channel, /api/add-channel, /api/update-channel, 
/api/delete-channel.
   - object/ormer.go: register the Channel table via Sync2 in createTable() so 
it is auto-created at startup.
   
   # Verification
   
   - go build ./... passes (go 1.20.14, module keeps go 1.16).
   - go vet ./object/ ./controllers/ ./routers/ reports zero warnings.
   - Data-layer unit test passes: add → get (raw key) → mask → update with 
masked key (real key preserved) → update with new key (key updated) → list → 
delete.
   - Live API test against a running server (http://:17000) passes for all six 
endpoints: add 4 channels, list shows 3 with masked keys (sk-o****-111), single 
get, update with masked key (HEX check confirms the real key 
sk-openai-real-key-111 is NOT overwritten), delete works.
   - The channel table is auto-created by Sync2 with the correct base_url 
column name.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to