-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add proxy pass route for id resolution #4356
Add proxy pass route for id resolution #4356
Conversation
@@ -50,4 +50,7 @@ plugins.elasticsearch { | |||
listing-bucket-size = 500 | |||
# set to false to disable Elasticsearch indexing | |||
indexing-enabled = ${app.defaults.indexing.enable} | |||
|
|||
# base to use to reconstruct resource identifiers in the proxy pass | |||
proxy-id-base = "https://bbp.epfl.ch" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about putting this one in the fusion config ?
(Which can be renamed)
Also localhost could be the default value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made the changes. Also renamed proxy-id-base
to resolve-base
. If not suitable we can still change it later
private def fusionResolveEndpoint(encodedId: String) = | ||
s"https://bbp.epfl.ch/nexus/web/resolve/$encodedId".replace("%3A", ":") | ||
private def deltaResolveEndpoint(encodedId: String) = | ||
s"http://delta:8080/v1/resolve/$encodedId".replace("%3A", ":") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be URL encoded?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I follow why it should be encoded? I don't think the location in a redirect needs to be encoded?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only the last segment is encoded because it needs to be a single segment representing the resource ID, and that can contain /
. Similar to how the id needs to be URL encoded when fetching resources, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if other unpredictable things could happen if url characters are in the ID
"redirect to fusion resolve if the request comes to the proxy endpoint with text/html accept header is present" in { | ||
deltaClient.get[String](s"/resolve-proxy-pass/$neurosciencegraphSegment", Bob, acceptTextHtml) { (_, response) => | ||
response.status shouldEqual StatusCodes.SeeOther | ||
locationHeaderOf(response) shouldEqual fusionResolveEndpoint(encodedNeurosciencegraphId) | ||
}(PredefinedFromEntityUnmarshallers.stringUnmarshaller) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dream assertion would be
response shouldBe redirectTo(fusionResolveEndpoint(encodedNeurosciencegraphId))
It would be really nice to get rid of this boilerplate too but I don't know how: (PredefinedFromEntityUnmarshallers.stringUnmarshaller)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah but with this option we'd be matching on the response body which is not really relevant
private def fusionResolveEndpoint(encodedId: String) = | ||
s"https://bbp.epfl.ch/nexus/web/resolve/$encodedId".replace("%3A", ":") | ||
private def deltaResolveEndpoint(encodedId: String) = | ||
s"http://delta:8080/v1/resolve/$encodedId".replace("%3A", ":") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if other unpredictable things could happen if url characters are in the ID
Closes #4347