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

Commit

Permalink
Check auth for Update Destination/Consumer Group (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bo Yang authored and datoug committed Jul 10, 2017
1 parent 9822edf commit 819b773
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions services/frontendhost/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -947,17 +947,18 @@ func (h *Frontend) UpdateDestination(ctx thrift.Context, updateRequest *c.Update
return
}

// Disallow delete destination for non-test destinations without a password
// TODO: remove when appropriate authentication is in place
if !allowMutate {
err := &c.BadRequestError{Message: fmt.Sprintf("Contact Cherami team to update this path: %v", updateRequest.GetPath())}
h.logger.WithField(common.TagErr, err).Error("Error updating destination")
return nil, err
}

// Local logger with additional fields
lclLg := h.logger.WithField(common.TagDstPth, common.FmtDstPth(updateRequest.GetPath()))

// To keep backward compatiblity, only check auth when no password is provided for DeleteDestination
if !allowMutate {
authResource := common.GetResourceURNOperateDestination(h.SCommon, updateRequest.Path)
_, err = h.checkAuth(ctx, authResource, common.OperationUpdate, lclLg)
if err != nil {
return
}
}

// Lookup the destination UUID
// TODO Caching? Seems like update destination will be low volume
destUUID, err := h.getUUIDForDestination(ctx, updateRequest.GetPath(), acceptDisabled)
Expand Down Expand Up @@ -1249,6 +1250,12 @@ func (h *Frontend) UpdateConsumerGroup(ctx thrift.Context, updateRequest *c.Upda
common.TagCnsPth: common.FmtCnsPth(updateRequest.GetConsumerGroupName()),
})

authResource := common.GetResourceURNOperateConsumerGroup(h.SCommon, updateRequest.DestinationPath, updateRequest.ConsumerGroupName)
_, err = h.checkAuth(ctx, authResource, common.OperationUpdate, lclLg)
if err != nil {
return
}

// Request to controller
var cClient controller.TChanController
cClient, err = h.getControllerClient()
Expand Down

0 comments on commit 819b773

Please sign in to comment.