Skip to content

Unable to generate short url for signed request #18

@ryanwi

Description

@ryanwi

Does the shortener support signed requests?

Given a standard thumbor signed request, this works fine:

http://localhost:8888/oNfnJ36sAQ-CEMVDFTgZ-DfpZ0Y=/360x220/smart/https://82bda53d6c07527f63d4-bb56d6c11261cc2ec250960b8872f9f2.ssl.cf1.rackcdn.com/roster_full_photos/168/original/e44118bf-cf2e-4777-8810-dea67f3e413f.jpg

But, shortening the url fails:

curl -X "POST" "http://localhost:8888/shortener/oNfnJ36sAQ-CEMVDFTgZ-DfpZ0Y=/360x220/smart/https://82bda53d6c07527f63d4-bb56d6c11261cc2ec250960b8872f9f2.ssl.cf1.rackcdn.com/roster_full_photos/168/original/e44118bf-cf2e-4777-8810-dea67f3e413f.jpg"

With the logs as follows:

2016-05-12 14:44:28 thumbor:WARNING Malformed URL: /shortener/oNfnJ36sAQ-CEMVDFTgZ-DfpZ0Y=/360x220/smart/https://82bda53d6c07527f63d4-bb56d6c11261cc2ec250960b8872f9f2.ssl.cf1.rackcdn.com/roster_full_photos/168/original/e44118bf-cf2e-4777-8810-dea67f3e413f.jpg
2016-05-12 14:44:28 tornado.access:WARNING 400 POST /shortener/oNfnJ36sAQ-CEMVDFTgZ-DfpZ0Y=/360x220/smart/https://82bda53d6c07527f63d4-bb56d6c11261cc2ec250960b8872f9f2.ssl.cf1.rackcdn.com/roster_full_photos/168/original/e44118bf-cf2e-4777-8810-dea67f3e413f.jpg (127.0.0.1) 1360.13ms

From what I can tell, the call to yield self.check_image(options) will fail because the method does not account for shortener being in the url. It will look like this:

(Pdb) url = self.request.path
(Pdb) url
'/shortener/oNfnJ36sAQ-CEMVDFTgZ-DfpZ0Y=/360x220/smart/https://82bda53d6c07527f63d4-bb56d6c11261cc2ec250960b8872f9f2.ssl.cf1.rackcdn.com/roster_full_photos/168/original/e44118bf-cf2e-4777-8810-dea67f3e413f.jpg'
(Pdb) url_to_validate = url.replace('/%s/' % options['hash'], '').replace('/%s/' % quote(options['hash']), '')
(Pdb) url_to_validate
'/shortener360x220/smart/https://82bda53d6c07527f63d4-bb56d6c11261cc2ec250960b8872f9f2.ssl.cf1.rackcdn.com/roster_full_photos/168/original/e44118bf-cf2e-4777-8810-dea67f3e413f.jpg'
(Pdb) url_signature = options['hash']
(Pdb) valid = signer.validate(unquote(url_signature), url_to_validate)
(Pdb) valid
False

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions