Skip to content

fix(auth): extend OAuth access token TTL from 1h to 7d - #49

Merged
mashkovd merged 1 commit into
mainfrom
fix/oauth-access-token-ttl-7d
May 10, 2026
Merged

mashkovd merged 1 commit into
mainfrom
fix/oauth-access-token-ttl-7d

Conversation

@mashkovd

Copy link
Copy Markdown
Member

Summary

  • Increases AccessTokenTTL from time.Hour to 7 * 24 * time.Hour
  • mctl-api stores refresh tokens in-memory (sync.Map) — any pod restart clears them
  • With 1h TTL, openclaw loses its mctl MCP connection within 1h of every mctl-api deploy
  • With 7d TTL, connections survive routine deploys without manual re-auth

Root cause

OAuthServer.refreshTokens is a sync.Map (in-memory). RefreshAccessToken uses loadAndDelete — refresh token is single-use and not persisted. Pod restart = all refresh tokens gone. After the access token expires (was 1h), openclaw cannot refresh and shows "Not connected".

Tradeoff

A compromised access token is valid for 7 days instead of 1h. Proper fix (persist refresh tokens in PostgreSQL) is deferred.

Test plan

  • Build passes: go build ./...
  • After deploy: re-auth in openclaw UI — token should show ~7d expiry
  • After next mctl-api deploy: openclaw connection survives without manual re-auth

mctl-api stores refresh tokens in-memory (sync.Map). Any pod restart
clears them, breaking openclaw MCP connections after 1h (access token
expiry). With a 7-day TTL the connection survives routine deploys.

Proper fix (persist refresh tokens in Postgres) deferred.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant