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

Check auth for Update Destination/Consumer Group #243

Merged
merged 1 commit into from
Jun 30, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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