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

LTI Redirection #2

Merged
merged 6 commits into from
Mar 16, 2017
Merged

Conversation

davidmsibley
Copy link
Contributor

@davidmsibley davidmsibley commented Mar 14, 2017

This is broken, I'm just opening a pull request to start a code review

I refactored a bit of the existing code and started writing a redirector.

The refactors were pulling HttpServletRequest from the Service scope, and pulling some common prep logic out to be used by the redirector. These should make unit testing the Service methods easier (though I haven't written any yet 🤷‍♂️)

The redirector is using the Spring Web's built in RestTemplate to hit the remote url. I opted to go with that over HttpComponents just to learn something new and to not pull in a dependency if I didn't need to. However, as it's written now, I'm getting a 501 back from the external service, so I may pull in HttpComponents just for the extra debugging information I know I can get out of it.

I looked at the rssToJson microservice and swapped in HttpComponents per that. Everything's a whole lot simpler. Locally I'm getting a 400 from the external service, but that's probably because I don't have true authentication set up. The real test of this will be out on predev.


logger.trace(new String(b));

if (303 == status) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

magic number. This possibly should be opened up as well to the 300-series, but right now I know that the service returns a 303 on success.

Copy link
Member

@apetro apetro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like progress. Progress is progress. 👍 .


/**
*
* @author sibley
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't favor @author annotations in shared-ownership codebases, but I recognize it's a matter of style and reasonable developers can differ on this point.

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 don't care for it either. I've since edited the new file templates to omit this and license information.

@RequestMapping(value="/go/{key}", method=RequestMethod.GET)
public void proxyRedirect(HttpServletRequest request, HttpServletResponse response, @PathVariable String key) throws
ClientProtocolException, IOException, LtiSigningException, URISyntaxException {
int statusCode = HttpServletResponse.SC_BAD_REQUEST;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest inline HttpServletResponse.SC_BAD_REQUEST the one place it's used in this method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

if (null != uri) {
response.sendRedirect(uri.toString());
} else {
response.sendError(statusCode, "Could not build redirect URI!");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest including {key} in error response.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@davidmsibley davidmsibley merged commit 21f143c into UW-Madison-DoIT:master Mar 16, 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