Skip to content

cdn: add sign_cookie example with tests #3281

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

Merged
merged 9 commits into from
Apr 29, 2020

Conversation

mpwarres
Copy link
Collaborator

@mpwarres mpwarres commented Apr 6, 2020

This PR expands the existing snippet for Cloud CDN Signed URLs to also illustrate Signed Cookies, a feature currently in closed alpha. This feature extends Cloud CDN's Signed URL functionality.

@mpwarres mpwarres requested a review from a team as a code owner April 6, 2020 04:04
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Apr 6, 2020
@mpwarres
Copy link
Collaborator Author

mpwarres commented Apr 6, 2020

@elithrar FYI

Copy link
Contributor

@kurtisvg kurtisvg left a comment

Choose a reason for hiding this comment

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

If this a sample for a closed alpha, why are we putting it in a public github repo?

Additionally, if you team owns these samples, please add yourself in the CODEOWNERs file.

@elithrar
Copy link

elithrar commented Apr 7, 2020

@kurtisvg This will go GA shortly (within a week) and we are attempting to sync this up with the need to be in the public docs for launch day.

Is there a better process to handle cases like this? We are not concerned about folks seeing this PR ahead of being merged.

@kurtisvg kurtisvg added the kokoro:run Add this label to force Kokoro to re-run the tests. label Apr 7, 2020
@kokoro-team kokoro-team removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Apr 7, 2020
@kurtisvg
Copy link
Contributor

kurtisvg commented Apr 7, 2020

@elithrar Most folks use GOB to stage samples when not publicly available, but if you aren't concerned about public knowledge this is fine.

We won't be able to merge it into master until the feature is publicly available, but you can ping me when that happens and I'll take care of it.

@mpwarres
Copy link
Collaborator Author

PTAL again:

  • Added code example and tests for Signed URL prefix.
  • Updated CODEOWNERS entry for /cdn/
  • Updated region tags.

Thanks!

@mpwarres mpwarres requested a review from kurtisvg April 13, 2020 17:41
@kurtisvg kurtisvg added the kokoro:run Add this label to force Kokoro to re-run the tests. label Apr 13, 2020
@kokoro-team kokoro-team removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Apr 13, 2020
@tmatsuo
Copy link
Contributor

tmatsuo commented Apr 23, 2020

@mpwarres

In case you don't have access to the build logs. Here is the lint output:

./snippets.py:182:5: F821 undefined name 'sign_cookie_parser'
    sign_cookie_parser.add_argument(
    ^

It seems like sign_cookie_parser is defined way below.

@mpwarres mpwarres requested a review from tmatsuo April 28, 2020 23:10
@tmatsuo tmatsuo added the kokoro:run Add this label to force Kokoro to re-run the tests. label Apr 29, 2020
@kokoro-team kokoro-team removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Apr 29, 2020
expiration_timestamp = int((expiration_time - epoch).total_seconds())
decoded_key = base64.urlsafe_b64decode(base64_key)

policy_pattern = u'URLPrefix={encoded_url_prefix}:Expires={expires}:KeyName={key_name}'
Copy link
Contributor

Choose a reason for hiding this comment

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

JFYI, from python 3.6, you can use f-string

Then it will be

policy = (
    f'URLPrefix={encoded_url_prefix}:Expires={expiration_timestamp}:'
    f'KeyName={key_name}'
)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

TIL--thanks!

@tmatsuo tmatsuo merged commit 154dce9 into GoogleCloudPlatform:master Apr 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants