How to force symfony2 to use HTTPS only for one page

I have to use HTTPS for only single page in symfony2 app. I've tried like

security.yml

- { path: ^/payment, roles: ROLE_USER, requires_channel: https } 

It works good but when i navigate to other pages from /payment page its stays same in HTTPS instead of HTTP. I've also tried something from sonata admin controller like:

PaymentAdmin.php

$collection
        ->add('makePayment', 'payment/{paymentId}',$options = array('_scheme' => 'https'));

but the same problem.simply i just want to use HTTPS only for /payment page not for other pages.how can i solve this issue.

Upvotes: 1

Views: 699

Answers (1)

antanas_sepikas
antanas_sepikas

Reputation: 5714

You could try adding regexp start notation "^" to your path like this "^/payment" which should state that routes which start with /payment should be in "https".

{ path: ^/payment, roles: ROLE_USER, requires_channel: https } 

The example in http://symfony.com/doc/current/cookbook/security/force_https.html also shows that.

Upvotes: 2

Related Questions