Add OBO token caching with proactive refresh for AG-UI ObO forwarding#11610
Add OBO token caching with proactive refresh for AG-UI ObO forwarding#11610mingshl wants to merge 2 commits intoopensearch-project:mainfrom
Conversation
ℹ️ Manual Changeset Creation ReminderPlease ensure manual commit for changeset file 11610.yml under folder changelogs/fragments to complete this PR. If you want to use the available OpenSearch Changeset Bot App to avoid manual creation of changeset file you can install it in your forked repository following this link. For more information about formatting of changeset files, please visit OpenSearch Auto Changeset and Release Notes Tool. |
PR Code Analyzer ❗AI-powered 'Code-Diff-Analyzer' found issues on commit ada87e0.
The table above displays the top 10 most important findings. Pull Requests Author(s): Please update your Pull Request according to the report above. Repository Maintainer(s): You can Thanks. |
|
Failed to generate code suggestions for PR |
✅ All unit and integration tests passing
|
Signed-off-by: Mingshi Liu <mingshl@amazon.com>
Signed-off-by: Mingshi Liu <mingshl@amazon.com>
2aef47d to
ada87e0
Compare
|
Failed to generate code suggestions for PR |
|
@cwperks would you please take a review of this change to refresh the obo token before it expired? |
|
@mingshl I don't have a good mental model of how agUI uses the token. Can you point me to any relevant documentation? Is there any signal that OSD gets from OpenSearch MCP Tools Service that let's it know that it has an expired token? |
Here is the RFC and the high level design in it. opensearch-project/OpenSearch#20602 the agui server is passing through the token to mcp server, and it will reach opensearch to authenticate. Agent server doesn't authenticate the token. The change I made in the PR, when generate the obo token, I get the obo token string and also mark down the duration. I will count the time before it expired before the duration, I will regenerate a new obo token to the streaming request. |
Description
durationSecondsfrom the security plugin API responsegetPrincipalsFromRequest(backed by cookie credentials throughHttpAuth) to key the cache safely per userContext
Follow-up to #11524. OBO tokens have a hard max TTL of 10 minutes (default 5 min) and there is no refresh endpoint — a new token must be minted each time. The cookie-stored credentials (available via
asCurrentUser) act as the long-lived "refresh token" to mint short-lived OBO tokens on demand.Issues Resolved
Screenshot
Testing the changes
Changelog
Check List
yarn test:jestyarn test:jest_integration