|
| 1 | +# Using CodeStream API behind Service Gateway |
| 2 | + |
| 3 | +Historically, the CodeStream API server accepted a bearer token in the Authorization |
| 4 | +header to authenticate all requests. The bearer token was a JSON Web Token (JWT) that |
| 5 | +encapsulated the CodeStream user ID in the payload. |
| 6 | + |
| 7 | +We are moving toward (and by the time you read this, we have fully moved to) a model |
| 8 | +whereby CodeStream relinquishes all responsibility for authentication to New Relic's |
| 9 | +login service. Under these circumstances, the bearer token that was used for the legacy |
| 10 | +API will be ignored. |
| 11 | + |
| 12 | +Instead, CodeStream is assumed to be operating on a secure, private network behind |
| 13 | +New Relic's request proxying service, entitled Service Gateway (SG). Identity information |
| 14 | +is passed in the form of request headers that Service Gateway adds to every request. |
| 15 | +For our purposes, we are interested in the 'service-gateway-user-id' header, which |
| 16 | +gives the New Relic user ID of the user sending the request. |
| 17 | + |
| 18 | +# Fake Service Gateway |
| 19 | + |
| 20 | +To avoid setting up a SG configuration for developer instances, or to develop on a |
| 21 | +laptop, developers can run a "fake" Service Gateway on their instance (or laptop). |
| 22 | +Fake Service Gateway (FSG) is an Elixir application that simulates the salient aspects |
| 23 | +of Service Gateway, basically acting like a local reverse proxy. FSG is easy to set up |
| 24 | +and use. |
| 25 | + |
| 26 | +Note that FSG still connects to New Relic's login service to authenticate the user's |
| 27 | +token (or api key, or cookie), so it is a not a standalone solution. Developers must |
| 28 | +still be connected to CHI VPN. |
| 29 | + |
| 30 | +Instructions for setting up FSG are here: |
| 31 | +[Fake Service Gateway]https://source.datanerd.us/unified-api/fake-service-gateway |
| 32 | + |
| 33 | +These instructions are pretty clear and need not be duplicated here. There is no need |
| 34 | +to run the dockerized version. You will, of course, need to install the certificate |
| 35 | +as suggested. |
| 36 | + |
| 37 | +Once you have setup the proxies.json file for your configuration, start the elixir app |
| 38 | +as stated in the instructions, then you simply need to point CodeStream's serverUrl |
| 39 | +to https://localhost.newrelic.com:${source_port}. |
0 commit comments