Skip to content

Commit dabc1b4

Browse files
rbeuque74loopfz
authored andcommitted
fix: auth: remove CtxKey type - involves breaking of SubTask authentication (#78)
1 parent 9c24c9c commit dabc1b4

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

api/middleware.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ func authMiddleware(authProvider func(*http.Request) (string, error)) func(c *gi
5353
c.AbortWithError(http.StatusUnauthorized, err)
5454
return
5555
}
56-
ctxKey := string(auth.IdentityProviderCtxKey)
57-
c.Set(ctxKey, user)
56+
c.Set(auth.IdentityProviderCtxKey, user)
5857
c.Next()
5958
}
6059
}

pkg/auth/auth.go

+1-6
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ import (
1212
"github.com/ovh/utask/pkg/utils"
1313
)
1414

15-
// CtxKey is a custom type based on string type
16-
// used to fix golint when IdentityProviderCtxKey
17-
// is set
18-
type CtxKey string
19-
2015
// IdentityProviderCtxKey is the key used to store/retrieve identity data from Context
2116
const IdentityProviderCtxKey = "__identity_provider_key"
2217

@@ -27,7 +22,7 @@ var (
2722

2823
// WithIdentity adds identity data to a context
2924
func WithIdentity(ctx context.Context, id string) context.Context {
30-
return context.WithValue(ctx, CtxKey(IdentityProviderCtxKey), id)
25+
return context.WithValue(ctx, IdentityProviderCtxKey, id)
3126
}
3227

3328
// Init reads authorization from configstore, bootstraps values

0 commit comments

Comments
 (0)