Skip to content

Commit

Permalink
fix: auth: remove CtxKey type - involves breaking of SubTask authenti…
Browse files Browse the repository at this point in the history
…cation (#78)
  • Loading branch information
rbeuque74 authored and loopfz committed Jan 21, 2020
1 parent 9c24c9c commit dabc1b4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
3 changes: 1 addition & 2 deletions api/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand Down
7 changes: 1 addition & 6 deletions pkg/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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
Expand Down

0 comments on commit dabc1b4

Please sign in to comment.