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
+5
View File
@@ -150,9 +150,14 @@ func GetAPIKey(ctx context.Context) string {
} }
func WithGrants(ctx context.Context, grants *auth.ClaimGrants, apiKey string) context.Context { 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{ return context.WithValue(ctx, grantsKey{}, &grantsValue{
claims: grants, claims: grants,
apiKey: apiKey, apiKey: apiKey,
expiresAt: expiresAt,
}) })
} }