bridge: support broker agent-token auth for send path#129
Merged
Conversation
Greptile SummaryAdds broker agent-token authentication support for outbound broker API requests. The registration flow now extracts and persists broker access token fields (token value, expiration timestamp, and scopes) from the Key Changes:
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Admin
participant BrokerRegister as broker-register.mjs
participant Broker as Broker Server
participant EnvFile as .env
participant Bridge as broker-bridge.mjs
participant BrokerAPI as Broker API
Admin->>BrokerRegister: sudo baudbot broker register
BrokerRegister->>Broker: POST /api/register
Note over BrokerRegister,Broker: Sends registration payload
Broker-->>BrokerRegister: broker_access_token<br/>broker_access_token_expires_at<br/>broker_access_token_scopes
BrokerRegister->>EnvFile: Write SLACK_BROKER_ACCESS_TOKEN<br/>SLACK_BROKER_ACCESS_TOKEN_EXPIRES_AT<br/>SLACK_BROKER_ACCESS_TOKEN_SCOPES
Note over Bridge: Bridge starts with env vars loaded
Bridge->>Bridge: Read SLACK_BROKER_ACCESS_TOKEN
loop Broker API Calls
Bridge->>BrokerAPI: POST /api/inbox/pull<br/>Authorization: Bearer {token}
BrokerAPI-->>Bridge: Messages
Bridge->>BrokerAPI: POST /api/send<br/>Authorization: Bearer {token}
BrokerAPI-->>Bridge: Success
Bridge->>BrokerAPI: POST /api/inbox/ack<br/>Authorization: Bearer {token}
BrokerAPI-->>Bridge: Acked
end
Last reviewed commit: d3aad0d |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/api/register:SLACK_BROKER_ACCESS_TOKENSLACK_BROKER_ACCESS_TOKEN_EXPIRES_ATSLACK_BROKER_ACCESS_TOKEN_SCOPESslack-bridge/broker-bridge.mjsto attachAuthorization: Bearer <token>automatically on broker API requests when token is configured (covers/api/sendenforcement).env.schema,CONFIGURATION.md,README.md,bin/config.sh)Why
modem-dev/baudbot-services#47adds optional broker token enforcement on/api/sendbehindREQUIRE_BROKER_AGENT_TOKEN=true. Without this client update, broker-mode outbound sends fail under enforcement.Testing
node --check slack-bridge/broker-bridge.mjsnode --check bin/broker-register.mjsnode --check test/broker-bridge.integration.test.mjsnode --test bin/broker-register.test.mjsnode --test slack-bridge/crypto.test.mjsbash -n bin/config.sh