Skip to content

Add LogContext middleware to inject org/user id#60

Closed
rndstr wants to merge 3 commits intomasterfrom
log-context-handler
Closed

Add LogContext middleware to inject org/user id#60
rndstr wants to merge 3 commits intomasterfrom
log-context-handler

Conversation

@rndstr
Copy link
Contributor

@rndstr rndstr commented Sep 20, 2017

We want to inject the organizationID and userID from named url path parameters in multiple places which this middleware helps with.

Not sure about the naming... open to alternatives.

@rndstr rndstr force-pushed the log-context-handler branch from 6e54101 to 1f1618e Compare September 20, 2017 15:00
@rndstr rndstr requested a review from leth September 20, 2017 15:01
@rndstr rndstr changed the title Add LogContextHandler() to inject org/user id Add LogContext middleware to inject org/user id Sep 20, 2017
@rndstr rndstr force-pushed the log-context-handler branch 2 times, most recently from 47ede04 to 73e938c Compare September 20, 2017 15:38
@rndstr rndstr force-pushed the log-context-handler branch from 73e938c to d584f19 Compare September 20, 2017 15:46
@rndstr rndstr requested a review from jml September 20, 2017 15:56
@leth
Copy link
Contributor

leth commented Sep 20, 2017

In other places we've sent the UserID and OrgID as HTTP headers, any reason for the departure from that?

@rndstr
Copy link
Contributor Author

rndstr commented Sep 20, 2017

@leth good point, I've seen both. Who is adding these HTTP headers? Clients? Authfe? And is there a middleware to extract it into the request context?

@leth
Copy link
Contributor

leth commented Sep 20, 2017

Fairly sure it's authfe; though the middleware lives in the users directory: https://github.com/weaveworks/service/blob/master/users/client/middleware.go

@jml
Copy link
Contributor

jml commented Sep 20, 2017

Sometimes in other clients directly too: https://github.com/weaveworks/cortex/blob/master/pkg/ruler/ruler.go#L223

return hj.Hijack()
}

// LogContext is a middleware to inject the organization and user id into

This comment was marked as abuse.

@rndstr
Copy link
Contributor Author

rndstr commented Sep 21, 2017

Main misconception was that there was no injection (since I didn't run it through authfe locally). Another revelation was that orgID != externalOrgID, so I'm closing this. Will also revert weaveworks/billing#180 and create a PR with minor improvements I stumbled upon.

@rndstr rndstr closed this Sep 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants