Skip to content
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

Merged
merged 9 commits into from
Oct 13, 2023

Conversation

olivergrabinski
Copy link
Contributor

@olivergrabinski olivergrabinski commented Oct 11, 2023

Closes #4347

Screenshot 2023-10-13 at 09-41-56 Id Resolution · Blue Brain Nexus

@olivergrabinski olivergrabinski marked this pull request as ready for review October 12, 2023 13:42
@@ -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"
Copy link
Contributor

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

Copy link
Contributor Author

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

shinyhappydan
shinyhappydan previously approved these changes Oct 13, 2023
Comment on lines +140 to +143
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", ":")
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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

Comment on lines 125 to 130
"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)
}
Copy link
Contributor

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)

Copy link
Contributor Author

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

Comment on lines +140 to +143
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", ":")
Copy link
Contributor

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

@olivergrabinski olivergrabinski merged commit cb4b6b1 into BlueBrain:master Oct 13, 2023
6 checks passed
@olivergrabinski olivergrabinski deleted the resolve-proxy-pass branch October 13, 2023 12:32
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.

Resolution of resources coming from proxy pass
3 participants