db: keep at most 1000 access tokens per OAuth client

Minting needs only the client secret, whatever its scopes, and
added one row per mint. Each mint now ends tokens past the newest 1000.
This commit is contained in:
Kristoffer Dalby committed 2026-10-28 07:15:55 +00:00
1 parent 8b3b6cf4b9
commit 9cdc33bae7
6 files changed
+86 -6

No files matched your search

+2 -2
View File
@@ -103,7 +103,7 @@ func oauthTokenHandler(b Backend) http.HandlerFunc {
expiry := time.Now().Add(accessTokenTTL)
tokenStr, _, err := b.State.MintAccessToken(client.ClientID, scopes, tags, &expiry)
tokenStr, token, err := b.State.MintAccessToken(client.ClientID, scopes, tags, &expiry)
if err != nil {
writeOAuthError(w, http.StatusInternalServerError, "server_error", "could not mint access token")
@@ -114,7 +114,7 @@ func oauthTokenHandler(b Backend) http.HandlerFunc {
AccessToken: tokenStr,
TokenType: "Bearer",
ExpiresIn: int(accessTokenTTL.Seconds()),
Scope: strings.Join(scopes, " "),
Scope: strings.Join(token.Scopes, " "),
})
}
}