Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- (Bugfix) Enable Platform Operator on EE Chart
- (Feature) Improve GRPC JSON Handling
- (Bugfix) Fix Operator Pod Resources
- (Feature) Improve Session & Route Handling

## [1.3.0](https://github.com/arangodb/kube-arangodb/tree/1.3.0) (2025-08-01)
- (Feature) (Platform) Storage Debug
Expand Down
33 changes: 24 additions & 9 deletions integrations/envoy/auth/v3/impl/auth_custom/openid/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,10 @@ func (i *impl) handleOpenIDAuthentication(ctx context.Context, request *pbEnvoyA
},
})

if _, err := i.session.Invalidate(ctx, cookie.Value); err != nil {
return err
}

continue
}

Expand All @@ -355,20 +359,31 @@ func (i *impl) handleOpenIDAuthentication(ctx context.Context, request *pbEnvoyA
continue
}

session, cookie, err := i.handleOpenIDRefresh(ctx, cfg, ocfg, session)
session, ok, _, err := i.session.Refresh(ctx, cookie.Value)
if err != nil {
return err
}

current.User = session.AsResponse()
if ok {
newSession, newCookie, err := i.handleOpenIDRefresh(ctx, cfg, ocfg, session)
if err != nil {
return err
}
Comment on lines +362 to +371
Copy link
Preview

Copilot AI Sep 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code calls i.session.Refresh() but ignores the returned duration (third parameter with _). This duration represents the time until session expiration and should be used to make informed decisions about whether refresh is needed or to set appropriate cache headers.

Copilot uses AI. Check for mistakes.


if cookie != nil {
current.ResponseHeaders = append(current.ResponseHeaders, &pbEnvoyCoreV3.HeaderValueOption{
Header: &pbEnvoyCoreV3.HeaderValue{
Key: "Set-Cookie",
Value: cookie.String(),
},
})
current.User = newSession.AsResponse()

if newCookie != nil {
current.ResponseHeaders = append(current.ResponseHeaders, &pbEnvoyCoreV3.HeaderValueOption{
Header: &pbEnvoyCoreV3.HeaderValue{
Key: "Set-Cookie",
Value: newCookie.String(),
},
})
}

if _, err := i.session.Invalidate(ctx, cookie.Value); err != nil {
return err
}
}

continue
Expand Down
10 changes: 9 additions & 1 deletion integrations/envoy/auth/v3/impl/session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import (
func NewManager[T any](ctx context.Context, t Type, client cache.Object[arangodb.Collection]) Manager[T] {
return manager[T]{
t: t,
cache: cache.NewRemoteCache[*session](client),
cache: cache.NewRemoteCacheWithTTL[*session](client, 5*time.Second),
}
}

Expand All @@ -47,6 +47,8 @@ type Manager[T any] interface {

Get(ctx context.Context, key string) (T, bool, time.Duration, error)

Refresh(ctx context.Context, key string) (T, bool, time.Duration, error)

Invalidate(ctx context.Context, key string) (bool, error)
}

Expand All @@ -55,6 +57,12 @@ type manager[T any] struct {
cache cache.RemoteCache[*session]
}

func (m manager[T]) Refresh(ctx context.Context, key string) (T, bool, time.Duration, error) {
m.cache.Invalidate(ctx, key)

return m.Get(ctx, key)
}

func (m manager[T]) Put(ctx context.Context, expires time.Time, obj T) (string, error) {
data, err := sharedApi.NewAny(obj)
if err != nil {
Expand Down
244 changes: 244 additions & 0 deletions integrations/shared/v1/definition/errors.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions integrations/shared/v1/definition/errors.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
// DISCLAIMER
//
// Copyright 2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//

syntax = "proto3";

package shared;

option go_package = "github.com/arangodb/kube-arangodb/integrations/shared/v1/definition";

// Path Error Details
message PathError {
// Path
string path = 1;
// Message
string message = 2;
}

// Path Error Details
message Error {
// Message
string message = 1;
}

8 changes: 8 additions & 0 deletions pkg/apis/shared/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"fmt"
"io"

pbSharedV1 "github.com/arangodb/kube-arangodb/integrations/shared/v1/definition"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
)

Expand All @@ -32,6 +33,13 @@ type ResourceError struct {
Err error
}

func (p ResourceError) AsGRPCError() *pbSharedV1.PathError {
Copy link
Preview

Copilot AI Sep 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method name 'AsGRPCError' doesn't match the interface 'AsGRCPError' defined in grpc/errors.go. Either fix the interface name or this method name to maintain consistency.

Copilot uses AI. Check for mistakes.

return &pbSharedV1.PathError{
Path: p.Prefix,
Message: p.Err.Error(),
}
}
Comment on lines +36 to +41
Copy link
Preview

Copilot AI Sep 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method returns a pointer to PathError but the interface in pkg/util/grpc/errors.go expects protoadapt.MessageV1. This type mismatch could cause runtime panics when the GRPC error conversion is used.

Copilot uses AI. Check for mistakes.


// Error return string representation of error
func (p ResourceError) Error() string {
return fmt.Sprintf("%s: %s", p.Prefix, p.Err.Error())
Expand Down
Loading