mirror of
https://github.com/juanfont/headscale.git
synced 2026-11-05 13:09:25 +09:00
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:
1 parent
8b3b6cf4b9
commit
9cdc33bae7
6 files changed
+86
-6
No files matched your search
@@ -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, " "),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user