Add grants expiry to Auth context (#4581)
This commit is contained in:
+7
-2
@@ -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,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user