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

Problem with creating a signature #41

Closed
keithslater opened this issue Feb 27, 2015 · 7 comments
Closed

Problem with creating a signature #41

keithslater opened this issue Feb 27, 2015 · 7 comments

Comments

@keithslater
Copy link

I just started using Glide and I am attempting to set up signatures for the images. I believe I'm about 99% there but I'm having a problem with it.

I am doing this -

$urlBuilder = UrlBuilderFactory::create($url, 'key');

$url = $urlBuilder->getUrl('image.php', ['image' => $path, 'w' => $width, 'h' => $height]);

When doing this, the result of $parts['path'] inside the getUrl method is /image.php.

However when doing this -

SignatureFactory::create('key')->validateRequest($request);

The output of $request->getPathInfo() in validateRequest() method is just a /.

Because of this, the signatures don't match. Any idea how I can fix this?

@renege
Copy link

renege commented Mar 1, 2015

Same here. Maybe someone can make a good example? Will be usable for everyone, looks like from the docs it's a create feature.

@reinink
Copy link
Contributor

reinink commented Mar 2, 2015

@keithslater Hmm, I'll have to take a closer look at this to understand what's going wrong. Are you able to provide me example URLs that you're working with?

@keithslater
Copy link
Author

Sure, I'm doing something like this - http://www.domain.com/image.php?image=company_logos/original/1.png&w=250&h=100

Then when I call it, I'm doing this -

$url = $urlBuilder->getUrl('image.php', ['image' => $path, 'w' => $width, 'h' => $height]);

Path would be - company_logos/original/1.png

@reinink
Copy link
Contributor

reinink commented May 22, 2015

Okay, so I think i see what's going wrong here. Glide is designed for URLs that work like this:

http://www.domain.com/img/company_logos/original/1.png&w=250&h=100

And then you would create a route within your app to accept those image requests, something like this:

get('/img/{path}', function ($path) {
    $glide->outputImage($path, $_GET);
});

The reason that URL isn't working for you is because image.php?image=company_logos/original/1.png&w=250&h=100 should resolve to /image.php when getPathInfo() is called.

To make a path like /img/company_logos/original/1.png work, you would have to setup URL rewriting, which is pretty standard on modern PHP projects.

Having said that, it would probably be helpful to offer something like this as well with Glide, instead of having to use the HttpFoundation request object for HTTP signatures:

SignatureFactory::create('key')->validateRequest($path, $_GET);

I'll add that to my to-do list.

@reinink
Copy link
Contributor

reinink commented May 22, 2015

As promised: 615861a

I'll get this tagged as soon as possible.

@reinink reinink closed this as completed May 22, 2015
@renege
Copy link

renege commented May 22, 2015

promising! can you please update docs also with a good example to use this signature-feature?

@keithslater
Copy link
Author

Awesome, thanks.

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

No branches or pull requests

3 participants