diff --git a/api/middleware.go b/api/middleware.go index 5428b035..eeeaaffc 100644 --- a/api/middleware.go +++ b/api/middleware.go @@ -53,8 +53,7 @@ func authMiddleware(authProvider func(*http.Request) (string, error)) func(c *gi c.AbortWithError(http.StatusUnauthorized, err) return } - ctxKey := string(auth.IdentityProviderCtxKey) - c.Set(ctxKey, user) + c.Set(auth.IdentityProviderCtxKey, user) c.Next() } } diff --git a/pkg/auth/auth.go b/pkg/auth/auth.go index a3059319..b2ce5c06 100644 --- a/pkg/auth/auth.go +++ b/pkg/auth/auth.go @@ -12,11 +12,6 @@ import ( "github.com/ovh/utask/pkg/utils" ) -// CtxKey is a custom type based on string type -// used to fix golint when IdentityProviderCtxKey -// is set -type CtxKey string - // IdentityProviderCtxKey is the key used to store/retrieve identity data from Context const IdentityProviderCtxKey = "__identity_provider_key" @@ -27,7 +22,7 @@ var ( // WithIdentity adds identity data to a context func WithIdentity(ctx context.Context, id string) context.Context { - return context.WithValue(ctx, CtxKey(IdentityProviderCtxKey), id) + return context.WithValue(ctx, IdentityProviderCtxKey, id) } // Init reads authorization from configstore, bootstraps values