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

need https option for aws stream #335

Closed
PaddyLock opened this issue Feb 27, 2014 · 11 comments
Closed

need https option for aws stream #335

PaddyLock opened this issue Feb 27, 2014 · 11 comments

Comments

@PaddyLock
Copy link

Hi, I need to be able to produce paths to https where needed for paths generated to AWS S3

At the moment I can only pull images from s3 over http.

My config is like so:

knp_gaufrette:
    adapters:
        amazon:
            amazon_s3:
                amazon_s3_id: amazonS3
                bucket_name: %s3_bucket%
                options:
                    create: true
    filesystems:
        amazonS3:
            adapter: amazon

    stream_wrapper: ~

liip_imagine:
    cache: 'amazon_s3'
    filter_sets:
        product:
            data_loader: stream.amazon
            quality: 60
            filters:
                thumbnail: { size: [194, 194], mode: inset }

The path produced for my image is like this:

http://helios-production.s3.amazonaws.com/product/uploads/images/products/bluebell-2.jpg

The issue is, I have no control over the http or https part. I would like to either produce a path with the correct scheme depending on if it's a secure page or not or like this:

//helios-production.s3.amazonaws.com/product/uploads/images/products/bluebell-2.jpg

ideally both.

Thanks

@makasim
Copy link
Collaborator

makasim commented Feb 27, 2014

you can do that defining object scheme object url option as it written in the doc.

@PaddyLock
Copy link
Author

I have included setObjectUrlOption to my services like this:

services:
    amazonS3:
        class: AmazonS3
        arguments:
            -
                key: %aws_key%
                secret: %aws_secret%
                # more S3 specific options, see \AmazonS3::__construct()

    liip_imagine.data.loader.stream.profile:
        class: "%liip_imagine.data.loader.stream.class%"
        arguments:
            - "@liip_imagine"
            - 'gaufrette://amazonS3/'
        tags:
            - { name: 'liip_imagine.data.loader', loader: 'stream.amazon' }

    helios.imagine.cache.resolver.amazon_s3:
        class: Liip\ImagineBundle\Imagine\Cache\Resolver\AmazonS3Resolver
        arguments:
            - "@amazonS3"
            - "%s3_bucket%"
        calls:
             # This calls $service->setObjectUrlOption('https', true);
             - [ setObjectUrlOption, [ 'https', true ] ]
        tags:
            - { name: 'liip_imagine.cache.resolver', resolver: 'amazon_s3' }

But how do I then use that in my config? and will it use the appropriate https/http when needed automatically? My config looks like this (including knp_gaufrette). At the moment it works but just uses http for everything so it seems helios.imagine.cache.resolver.amazon_s3 is getting ignored?

knp_gaufrette:
    adapters:
        amazon:
            amazon_s3:
                amazon_s3_id: amazonS3
                bucket_name: %s3_bucket%
                options:
                    create: true
    filesystems:
        amazonS3:
            adapter: amazon

    stream_wrapper: ~

liip_imagine:
    cache: 'amazon_s3'
    filter_sets:
        product:
            data_loader: stream.amazon
            quality: 60
            filters:
                thumbnail: { size: [194, 194], mode: inset }

Thanks

@makasim
Copy link
Collaborator

makasim commented Mar 4, 2014

But how do I then use that in my config? and will it use the appropriate https/http when needed automatically? My config looks like this (including knp_gaufrette). At the moment it works but just uses http for everything so it seems helios.imagine.cache.resolver.amazon_s3 is getting ignored?

Honestly saying I dont know. I've never used this functionality. I believe by setting https to true you tell amazon to use it all the time.

@PaddyLock
Copy link
Author

At the moment it doesn't get used at all though. Do I need to use the service I have created called 'helios.imagine.cache.resolver.amazon_s3' somewhere?

@makasim
Copy link
Collaborator

makasim commented Mar 5, 2014

it has to work if you have configured everything as you posted it here. You added a tag to the resolver service and after in configuration you used the name from the tag. This way it is expected to work

@PaddyLock
Copy link
Author

Sorry, yes my bad, it does work, but only when I try it on the live server which has https. It also makes all image paths start with https. So, what I need to figure out is how to conditionally use https or http depending if it's a secure page or not. Do I have two services, one with
[ setObjectUrlOption, [ 'https', true ] ]
and one with
[ setObjectUrlOption, [ 'https', false ] ]
and then how do I switch between the two? do I have to conditionally switch in the twig template every time I use a filter? Do I have to have two sets of filters? There doesn't appear to be an easy solution to this. Surely there must be a way?

Thanks

@havvg
Copy link
Contributor

havvg commented Mar 10, 2014

Do you have secure and insecure pages on the same environment? Like you actually need to use the correct protocol, or is it just the lack of https on your dev env?

@havvg havvg added this to the v0.20.x milestone Mar 10, 2014
@PaddyLock
Copy link
Author

I have secure and insecure pages. I thought I had resolved the issue but alas no. Here is an updated services and config now with cacert which I needed to resolve a curl error certificate error described here - http://docs.aws.amazon.com/aws-sdk-php/guide/latest/faq.html

First I installed an up to date curl cacert.pem on my server

Then I have the following in my services.yml

services:
    amazonS3:
        class: AmazonS3
        arguments:
            -
                key: %aws_key%
                secret: %aws_secret%
                ssl.certificate_authority: '/etc/ssl/certs/cacert.pem'
                # more S3 specific options, see \AmazonS3::__construct()

    liip_imagine.data.loader.stream.profile:
        class: "%liip_imagine.data.loader.stream.class%"
        arguments:
            - "@liip_imagine"
            - 'gaufrette://amazonS3/'
        tags:
            - { name: 'liip_imagine.data.loader', loader: 'stream.amazon' }

    helios.imagine.cache.resolver.amazon_s3:
        class: Liip\ImagineBundle\Imagine\Cache\Resolver\AmazonS3Resolver
        arguments:
            - "@amazonS3"
            - "%s3_bucket%"
        calls:
             # This calls $service->setObjectUrlOption('https', false);
             # I need to be able to set or override this option conditionaly
             - [ setObjectUrlOption, [ 'https', false ] ]
        tags:
            - { name: 'liip_imagine.cache.resolver', resolver: 'amazon_s3' }

And then in my config

cybernox_amazon_web_services:
    key:                        %aws_key%
    secret:                     %aws_secret%
    default_cache_config:       apc
    enable_extensions:          []
    certificate_authority:      true
    disable_auto_config:        true

knp_gaufrette:
    adapters:
        amazon:
            amazon_s3:
                amazon_s3_id: amazonS3
                bucket_name: %s3_bucket%
                options:
                    create: true
    filesystems:
        amazonS3:
            adapter: amazon

    stream_wrapper: ~

liip_imagine:
    cache: 'amazon_s3'
    filter_sets:
        product:
            data_loader: stream.amazon
            quality: 60
            filters:
                thumbnail: { size: [194, 194], mode: inset }

@PaddyLock
Copy link
Author

I have updated above comment as I haven't resolved the issue. I have secure and insecure pages, hence my problem.

@makasim makasim modified the milestones: v1.1, v0.20.x May 22, 2014
@makasim
Copy link
Collaborator

makasim commented May 22, 2014

moving to 1.1 milestone as 0.20 is not supported any more.

@robfrawley robfrawley removed State: Rejected This item has been rejected as being invalid or otherwise not desired by maintainers. Attn: Critical This issue or PR is critical and should be rushed into a new release ASAP. labels Sep 27, 2016
@robfrawley robfrawley removed this from the v1.1-missed milestone Jan 25, 2017
@michellesanver
Copy link
Contributor

michellesanver commented Oct 4, 2019

@PaddyLock I am going through all issues to sort and prioritise. Is this still an issue for you? Since this is so old, please open a new issue if that is the case and we will prioritise accordingly. Thanks a lot! :)

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

5 participants