|
| 1 | +// |
| 2 | +// DISCLAIMER |
| 3 | +// |
| 4 | +// Copyright 2025 ArangoDB GmbH, Cologne, Germany |
| 5 | +// |
| 6 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | +// you may not use this file except in compliance with the License. |
| 8 | +// You may obtain a copy of the License at |
| 9 | +// |
| 10 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +// |
| 12 | +// Unless required by applicable law or agreed to in writing, software |
| 13 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +// See the License for the specific language governing permissions and |
| 16 | +// limitations under the License. |
| 17 | +// |
| 18 | +// Copyright holder is ArangoDB GmbH, Cologne, Germany |
| 19 | +// |
| 20 | + |
| 21 | +package request_id |
| 22 | + |
| 23 | +import ( |
| 24 | + "context" |
| 25 | + |
| 26 | + pbEnvoyCoreV3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" |
| 27 | + pbEnvoyAuthV3 "github.com/envoyproxy/go-control-plane/envoy/service/auth/v3" |
| 28 | + "k8s.io/apimachinery/pkg/util/uuid" |
| 29 | + |
| 30 | + pbImplEnvoyAuthV3Shared "github.com/arangodb/kube-arangodb/integrations/envoy/auth/v3/shared" |
| 31 | + utilConstants "github.com/arangodb/kube-arangodb/pkg/util/constants" |
| 32 | +) |
| 33 | + |
| 34 | +func New(ctx context.Context, configuration pbImplEnvoyAuthV3Shared.Configuration) (pbImplEnvoyAuthV3Shared.AuthHandler, bool) { |
| 35 | + return impl{}, true |
| 36 | +} |
| 37 | + |
| 38 | +type impl struct { |
| 39 | +} |
| 40 | + |
| 41 | +func (a impl) Handle(ctx context.Context, request *pbEnvoyAuthV3.CheckRequest, current *pbImplEnvoyAuthV3Shared.Response) error { |
| 42 | + var header = pbEnvoyCoreV3.HeaderValueOption{ |
| 43 | + Header: &pbEnvoyCoreV3.HeaderValue{ |
| 44 | + Key: utilConstants.EnvoyRequestIDHeader, |
| 45 | + Value: string(uuid.NewUUID()), |
| 46 | + }, |
| 47 | + } |
| 48 | + current.Headers = append(current.Headers, &header) |
| 49 | + current.ResponseHeaders = append(current.ResponseHeaders, &header) |
| 50 | + |
| 51 | + return nil |
| 52 | +} |
0 commit comments