Skip to content

Commit 693c92c

Browse files
committed
Iter
1 parent 216917d commit 693c92c

File tree

5 files changed

+10
-65
lines changed

5 files changed

+10
-65
lines changed

integrations/authentication/v1/implementation.go

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -171,21 +171,12 @@ func (i *implementation) CreateToken(ctx context.Context, request *pbAuthenticat
171171
// Token is validated, we can continue with creation
172172
secret := cache.token
173173

174-
<<<<<<< HEAD
175-
signedToken, err := token.New(secret,
176-
token.NewClaims().With(token.WithDefaultClaims(),
177-
token.WithCurrentIAT(),
178-
token.WithDuration(duration),
179-
token.WithUsername(user),
180-
token.WithRoles(request.GetRoles()...)),
181-
)
182-
=======
183174
signedToken, err := token.NewClaims().With(
184175
token.WithDefaultClaims(),
185176
token.WithCurrentIAT(),
186177
token.WithDuration(duration),
187-
token.WithUsername(user)).Sign(secret)
188-
>>>>>>> bbaf385d5 ([Bugfix] Fix JWT Secret Tail characters)
178+
token.WithUsername(user),
179+
token.WithRoles(request.GetRoles()...)).Sign(secret)
189180
if err != nil {
190181
return nil, err
191182
}
@@ -248,14 +239,9 @@ func (i *implementation) Identity(ctx context.Context, _ *pbSharedV1.Empty) (*pb
248239
return nil, status.Error(codes.Unauthenticated, "Unauthenticated")
249240
}
250241

251-
<<<<<<< HEAD
252242
func (i *implementation) extractTokenDetails(cache *cache, t string) (string, []string, time.Duration, error) {
253243
// Let's check if token is signed properly
254-
=======
255-
func (i *implementation) extractTokenDetails(cache *cache, t string) (string, time.Duration, error) {
256-
// Token is validated, we can continue with creation
257244
secret := cache.token
258-
>>>>>>> bbaf385d5 ([Bugfix] Fix JWT Secret Tail characters)
259245

260246
// Let's check if token is signed properly
261247
p, err := secret.Validate(t)
@@ -272,7 +258,9 @@ func (i *implementation) extractTokenDetails(cache *cache, t string) (string, ti
272258

273259
duration := DefaultTokenMaxTTL
274260

275-
if v, ok := p.Claims()[token.ClaimEXP]; ok {
261+
claims := p.Claims()
262+
263+
if v, ok := claims[token.ClaimEXP]; ok {
276264
switch o := v.(type) {
277265
case int64:
278266
duration = time.Until(time.Unix(o, 0))
@@ -283,7 +271,7 @@ func (i *implementation) extractTokenDetails(cache *cache, t string) (string, ti
283271

284272
var roles []string
285273

286-
if v, ok := p[token.ClaimRoles]; ok {
274+
if v, ok := claims[token.ClaimRoles]; ok {
287275
switch o := v.(type) {
288276
case []string:
289277
roles = o

pkg/api/auth.go

Lines changed: 1 addition & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/api/jwt.go

Lines changed: 0 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/deployment/resources/secrets.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ import (
2727
"fmt"
2828
"time"
2929

30-
<<<<<<< HEAD
31-
jwt "github.com/golang-jwt/jwt/v5"
32-
=======
33-
>>>>>>> bbaf385d5 ([Bugfix] Fix JWT Secret Tail characters)
3430
core "k8s.io/api/core/v1"
3531
"k8s.io/apimachinery/pkg/api/equality"
3632
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -427,19 +423,12 @@ func AppendKeyfileToKeyfolder(ctx context.Context, cachedStatus inspectorInterfa
427423
}
428424

429425
var (
430-
<<<<<<< HEAD
431-
exporterTokenClaims = jwt.MapClaims{
432-
token.ClaimISS: token.ClaimISSValue,
433-
"server_id": "exporter",
434-
"allowed_paths": []interface{}{"/_admin/statistics", "/_admin/statistics-description",
435-
=======
436426
exporterTokenClaimsMods = []util.ModR[token.Claims]{
437427
token.WithDefaultClaims(),
438428
token.WithServerID("exporter"),
439429
token.WithAllowedPaths(
440430
"/_admin/statistics",
441431
"/_admin/statistics-description",
442-
>>>>>>> bbaf385d5 ([Bugfix] Fix JWT Secret Tail characters)
443432
shared.ArangoExporterInternalEndpoint,
444433
shared.ArangoExporterInternalEndpointV2,
445434
shared.ArangoExporterUsageEndpoint,
@@ -504,21 +493,12 @@ func (r *Resources) ensureExporterTokenSecretCreateRequired(cachedStatus inspect
504493
return true, true, errors.WithStack(err)
505494
}
506495

507-
<<<<<<< HEAD
508-
token, err := token.Parse(string(data), []byte(secret))
509-
510-
=======
511496
tokenClaims, err := secret.Validate(string(data))
512-
>>>>>>> bbaf385d5 ([Bugfix] Fix JWT Secret Tail characters)
513497
if err != nil {
514498
return true, true, nil
515499
}
516500

517-
<<<<<<< HEAD
518-
tokenClaims := jwt.MapClaims(token)
519-
=======
520501
expectedClaims := token.NewClaims().With(exporterTokenClaimsMods...)
521-
>>>>>>> bbaf385d5 ([Bugfix] Fix JWT Secret Tail characters)
522502

523503
return !equality.Semantic.DeepDerivative(tokenClaims, expectedClaims), true, nil
524504
}

pkg/util/mod.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,6 @@ func ApplyModsEP1[T, P1 any](in *T, p1 P1, mods ...ModEP1[T, P1]) error {
9292
return nil
9393
}
9494

95-
func emptyModR[T any](z T) T { return z }
96-
9795
type ModR[T any] func(in T) T
9896

9997
func (m ModR[T]) Optional() ModR[T] {
@@ -106,9 +104,9 @@ func (m ModR[T]) Optional() ModR[T] {
106104

107105
func ApplyModsR[T any](in T, mods ...ModR[T]) T {
108106
for _, mod := range mods {
109-
if mod != nil {
110-
mod(in)
111-
}
107+
in = mod(in)
112108
}
113109
return in
114110
}
111+
112+
func emptyModR[T any](z T) T { return z }

0 commit comments

Comments
 (0)