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

(develop) Added User-Agent in graph.py to prevent server blocking #219

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

jeroenlicht
Copy link

Many websites are configured to block requests with a missing User-Agent
For me this was causing an error for FETCH_HTTP_NODE on validating my assertion json url:
"Unknown Content-Type (Not image/png or image/svg+xml)"

It was solved after adding
'User-Agent': 'Open Badges Validator Core'
to the headers on line 40 of verifier/tasks/graph.py

Many websites are configured to block requests with a missing User-Agent
For me this was causing an error for FETCH_HTTP_NODE on validating my assertion json url:
"Unknown Content-Type (Not image/png or image/svg+xml)"

It was solved after adding  
'User-Agent': 'Open Badges Validator Core'
to the headers on line 40 of verifier/tasks/graph.py
@jeroenlicht jeroenlicht changed the title Update graph.py Added User-Agent header in for validation requests in graph.py Sep 1, 2019
@jeroenlicht jeroenlicht changed the title Added User-Agent header in for validation requests in graph.py Added User-Agent in headers for validation requests in graph.py Sep 1, 2019
@jeroenlicht jeroenlicht changed the title Added User-Agent in headers for validation requests in graph.py Added User-Agent in headers for FETCH_HTTP_NODE request to prevent server blocking Sep 1, 2019
@jeroenlicht jeroenlicht changed the title Added User-Agent in headers for FETCH_HTTP_NODE request to prevent server blocking Added User-Agent in headers to prevent server blocking Sep 1, 2019
@jeroenlicht jeroenlicht changed the title Added User-Agent in headers to prevent server blocking Added User-Agent in graph.py to prevent server blocking Sep 1, 2019
@jeroenlicht jeroenlicht changed the title Added User-Agent in graph.py to prevent server blocking (develop) Added User-Agent in graph.py to prevent server blocking Sep 1, 2019
@ottonomy
Copy link
Collaborator

ottonomy commented Sep 3, 2019

Thanks, @jeroenlicht. CC: @mumitr0ll I'm not against these suggested changes, though it is probably something worth of a spec errata discussion in the workgroup (and ideally somebody could do the work to merge together all the suggested changes into one combined PR for discussion, though I suspect @jeroenlicht you used the github in-browser UI to create these, and multi-file edits would have been more difficult). The spec and its conformance requirements do not mention any option for Open Badges issuer role applications to not serve requests that do not have a user agent header. In fact, because the conformance suite includes the unpatched validator, such an issuer implementation would not currently pass IMS conformance tests, so it's up to the workgroup as to whether the described server feature that it could be "configured to block requests with a missing User-Agent" header would be compatible with the spec. To my reading, the Accept header is the only header specifically mentioned by the spec that the validation request SHOULD include.

(if we go forward with this, I suggest we follow the recommended User-Agent string formatting suggested at MDN, which is User-Agent: <product> / <product-version> <comment>)

@jeroenlicht
Copy link
Author

jeroenlicht commented Sep 3, 2019

Thank you for the quick response @ottonomy , as well as for the suggestion for a better agent name.
Indeed I've been using the browser UI for these changes after a weekend of searching for why my assertions were not validating. Initially just this one, but then while I was at it anyway, I decided to also included commits for the other get requests I could find in the code.
I can understand that it might be better for Open Badges service providers if all Open Badges issuers can be assumed to handle requests without the user-agent header, and I will contact my hosting provider to ask whether and how we could add exceptions for the Open Badges endpoints.
However, if it is decided that the issuer should be forced to accept request without a user-agent header, may I suggest adding an extra check for this in the validor to give a more informative feedback about this to other Open Badges issuers who might run into the same problem?

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.

2 participants