-
-
Notifications
You must be signed in to change notification settings - Fork 867
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
[s3] Add support for signing CloudFront URLs #587
[s3] Add support for signing CloudFront URLs #587
Conversation
5b36b22
to
11c319a
Compare
Why even deal with multiple possible keys via |
The warning or having multiple keys? I put it that way so you can have the key definition in one place (your settings.py), but have multiple storages which reference different buckets or different accounts (you may be allowed to sign CloudFront URLs for a different project if they have delegated permissions). Either way there needs to be a |
3db5d6c
to
b5a0f05
Compare
Friendly reminder |
Ping |
@jschneier anymore thoughts about this PR? |
Any news about this? |
I'd love to see this soon! |
I was about to implement that myself, any news on this PR? |
+1 |
For those that need this now you can install via an editable install in your requirements.txt w/ the following |
One other option that builds off the solution by @terencehonles: You can extended the |
b5a0f05
to
50203b7
Compare
Does this repo have an active maintainer? Seems like there is 100% consensus to get this merged. |
It depends on how you define active I suppose. It comes in bursts for me
anyway. I do intend to look more at this one, sure.
…On Wednesday, November 6, 2019, cobyrne09 ***@***.***> wrote:
Does this repo have an active maintainer?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#587?email_source=notifications&email_token=AAREDWH6WMIRFSLOER67SC3QSNLTZA5CNFSM4FTNW7OKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDINRZY#issuecomment-550557927>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAREDWEG7DNOOKQP3U2J4GTQSNLTZANCNFSM4FTNW7OA>
.
|
50203b7
to
2319ed9
Compare
Hi, this looks okay. I'd rather we just do a single |
2319ed9
to
589da7b
Compare
@jschneier yeah I'll update this PR, I was doing my normal updating forks, but w/o looking at this PR when updating last. |
589da7b
to
128d8c3
Compare
@terencehonles So, how do I make cloudfront signing work? What do I have to specify in settings and how do I get the url? BTW, is there a way to set expiration time? |
@jschneier could you please release this version to PIP so it can be used in projects as dependency? |
@terencehonles what exactly should be supplied for AWS_CLOUDFRONT_KEY? Should it be a path to some kind of pem file or some secret key? Either way I get
|
Okay, I guess something like this works:
|
@DataGreed glad you figured it out, I guess I probably should have seen if there was documentation I could have added to. Did you want to open a PR to potentially add your suggestion?
My keyfile is inline (actually an ENV VAR) instead of read via a file like your example, but I think what you wrote would get the point across. One comment is you can open your file in binary mode and you will get bytes and not have to So: with open(os.path.join(BASE_DIR, 'keyfile.pem'), 'rb') as cert:
AWS_CLOUDFRONT_KEY = cert.read() |
@terencehonles oh thanks! That makes more sense. Sure, I can try extend the docs if you won't be able to do it. @terencehonles btw, is there any way to change the expiration time? |
When will the patch version be published with the official package? |
I might be able to get to it, but I'm encouraging you to also contribute to the project just like I did 😉
@DataGreed the expiration will be defined by the value you pass to the storage |
Hi, Has anybody got this to work ? I will extend the docs to hopefully save other peoples time once I manage to get the CloudFront signing working but at the moment I can't seem to get it going. My Process:
The Key file is inline as specified by @terencehonles but I still seem to get the buffer error @DataGreed mentioned I'll keep playing around with it, and update this comment as I go. EDIT 1I have added
Which fixes the buffer error but raises a new one:
EDIT 2:The value of the key in my ENV VAR was wrong because the key contained an equal sign and my ENV parser considered it as another ENV VAR. I have made a PR to update the docs #900 |
@terencehonles could you please tell me if there is any way to make the specific URL never expire? Should I just pass a ridiculously high timestamp or |
@DataGreed I pointed to the AWS docs in the PR description, and you can see this section Private Content Overview: Choosing Duration. A long duration may work for you, but if not, you will not be able to use a "Canned Policy" and you can see the differences here. This PR only implements a "Canned Policy" and you would have to alter the storage in order to provide a custom policy. You may even want to go as far as trying to validate that it is a valid policy (or is at least valid JSON) |
@terencehonles than you so much for giving a detailed answer. I think the longer expiration date will work for me - some of the uploaded files are public (like images) and should be used in open graph tags which facebook caches for some unspecified amount of time and some private file links should be valid for just a day. In my case I was trying to make public links valid for longer period of time so opengraph images won't suddenly break. I guess if it will allow me to set 100 years, I am all set :D I did not find any limitation description in Amazon docs, but one of the articles you posted above says
I'll post a follow up telling if it was a success or not. |
@SkiFamily Hey man, how did you manage to go above equal (=) sign in env? I'm getting the same error as you, and not sure how to proceed. Thanks. |
Forgot to follow up, my bad. It was a success – you can set 100 years as expiration time. |
|
Fixes #456. Similar to #484 but uses AWS CloudFront signed URLS (See AWS docs)
This is probably the right way to approach the problem in #484, but if that solution works that might be an alternative (not sure how @mattjegan configured S3+CloundFront)