Add grants expiry to Auth context (#4581)

This commit is contained in:
cnderrauber
2026-06-10 17:44:58 +08:00
committed by GitHub
parent 7dc6877738
commit 816d37281d
+7 -2
View File
@@ -150,9 +150,14 @@ func GetAPIKey(ctx context.Context) string {
}
func WithGrants(ctx context.Context, grants *auth.ClaimGrants, apiKey string) context.Context {
return WithGrantsExpiry(ctx, grants, apiKey, time.Time{})
}
func WithGrantsExpiry(ctx context.Context, grants *auth.ClaimGrants, apiKey string, expiresAt time.Time) context.Context {
return context.WithValue(ctx, grantsKey{}, &grantsValue{
claims: grants,
apiKey: apiKey,
claims: grants,
apiKey: apiKey,
expiresAt: expiresAt,
})
}