Skip to content
This repository has been archived by the owner on Feb 18, 2021. It is now read-only.

Commit

Permalink
Pass thrift header to authenticate context
Browse files Browse the repository at this point in the history
  • Loading branch information
Bo Yang committed May 25, 2017
1 parent 4f48ff9 commit d6f8ce2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion services/frontendhost/frontend.go
Expand Up @@ -60,6 +60,9 @@ type ContextKey string
// ResourceUrnKey is the context key name for resourceUrn
var ResourceUrnKey = ContextKey("resourceUrn")

// HeaderKey is the context key name for header
var HeaderKey = ContextKey("header")

var nilRequestError = &c.BadRequestError{Message: `request must not be nil`}
var badRequestKafkaConfigError = &c.BadRequestError{Message: `kafka destination must set kafka cluster and topic, and may not be multi-zone`}
var badRequestNonKafkaConfigError = &c.BadRequestError{Message: `non-Kafka destination must not set kafka cluster and topic`}
Expand Down Expand Up @@ -1645,8 +1648,12 @@ func (h *Frontend) getControllerClient() (controller.TChanController, error) {
return cf.GetControllerClient()
}

func (h *Frontend) checkAuth(ctx context.Context, authResource string, operation common.Operation, logger bark.Logger) error {
func (h *Frontend) checkAuth(ctx thrift.Context, authResource string, operation common.Operation, logger bark.Logger) error {
authContext := context.WithValue(ctx, ResourceUrnKey, authResource)
if ctx.Headers() != nil {
authContext = context.WithValue(authContext, HeaderKey, ctx.Headers())
}

authSubject, err := h.GetAuthManager().Authenticate(authContext)
if err != nil {
logger.WithFields(bark.Fields{
Expand Down

0 comments on commit d6f8ce2

Please sign in to comment.