Maxmind R2 presigned URLs

AI-generated summary

The discussion revolves around Maxmind’s upcoming change to use R2 presigned URLs for database downloads starting May 1, 2024, and whether this affects Discourse’s integration. mcdanlj raises the question after receiving an email from Maxmind. Arkshine notes that while Maxmind’s direct links should redirect automatically, Discourse’s current code (in discourse_ip_info.rb) doesn’t follow redirects — which could cause failures. However, pfaffman counters that redirects are actually handled, citing a previous fix (PR #26333) and a related support thread. pfaffman confirms that enabling redirects in the code resolves the issue and that automated tests pass. mcdanlj expresses relief at not having to set up local testing, and pfaffman notes the fix was simple — just one word — and tested successfully. The consensus is that Discourse should handle the change without issue, especially if redirects are properly supported, which they are per recent code updates.

Just got an email from Maxmind:

As of Wednesday, May 1, 2024, we will use R2 presigned URLs for all database downloads in order to increase the security and reliability of our services.

Does anyone know whether this affects Discourse’s Maxmind usage?

Good point!

Based on this article

It would seem that a direct link (what Discourse uses) will be fine as it is. This means it will be
automatically redirected to their new URLs. So far, so good.

However, from what I see in the code, it doesn’t follow redirection: This will likely fail.
You would need to update the URL or allow redirection to fix this.

It does.

https://github.com/discourse/discourse/pull/26333

I wonder whether they recently started using redirects before implementing the presigned URLs.

I just know that changing the code to allow redirects makes it work.

I was about to start looking to see whether there were any tests that would fail with that change, and you beat me to it! :smiling_face:

Well, it was a single word, and I’d already been hacking at the code on a live site, so it wasn’t that hard. Looks like all of the automated tests passed. . .

Oh, I’d been thinking that I would have to remember how to run all the tests locally, and I’ve reinstalled since the last time I did that so I was pretty sure that would be a rabbit hole of finding and installing dependencies… Just let the automation take care of it is smart. :smiling_face: