rest - Is CSRF token the cause for not be able to get authentificated in CURL command? -


The FOSSTBundle is fully working in my project but without authentication. Now, my goal is to make my requests with auth.

To do this, I have added this firewall to security.yml

  firewall: # ... main: Pattern: / Form_login: Provider: fos_userbundle remember_me: True login_path: / login check_path: / login_check default_target_path: minn_ads_default_index csrf_provider: form.csrf_provider Remember: key:% secret% rest_api: Pattern: ^ / api / stateless: true http_basic: Provider: fos_userbundle # ... access_control: # .. In order to check the certification in the curl order, I tried this command:  
 

code> curl -i \ -H 'accept: application / js '\' H: Authority: Basic DG9UXxxJoxMJM 0 '\ http: //localhost/tuto/app_dev.php/api/test/1

Where dG9uaXZkdjoxMjM0 = encode_base64 (' tonivdv : 1234 ')

The result is:

  HTTP / 1.1 302 found Date: Fri, 11 April 2014 13:56:08 GMT Server: Apache / 2.2.22 (Ubuntu) By X-Power: PHP / 5.4.9-4ubuntu2.4 Set-Cookie: PHPSE SSID = 4dtr168vmj1eg523a07kbkjkh1; Path = / cache-control: no-cache location: http: //localhost/tuto/web/app_dev.php/login variant: acceptable-language x-debug-token: 220df7 transfer-encoding: checked content-type: application / Jason & lt ;! DOCTYPE html & gt; & Lt; Html & gt; & Lt; Top & gt; & Lt; Meta http-equiv = "content-type" content = "text / html; charset = UTF-8" /> & Lt; Meta http-equiv = "refresh" content = "1; url = http: //localhost/tuto/web/app_dev.php/login" /> & Lt; Title & gt; Http: //localhost/tuto/web/app_dev.php/login< / Title & gt; Redirecting to; & Lt; / Head & gt; & Lt; Body & gt; & Lt; a href = "http: //localhost/tuto/web/app_dev.php/login" & gt; Http: //localhost/tuto/web/app_dev.php/login< / A & gt; Redirect to. & Lt; / Body & gt; & Lt; / Html & gt;   

So I am thinking that CSRF token FOSUserBandal is due to not being authenticated in curl order?

OK, your rest_api firewall will never be used because it happens after the main firewall Which will always match. This means that your API is protected through Stuttgable Form_Login Aith, not via http_basic.

  Firewall: rest_api: pattern: ^ / api / stateless: true http_basic: Provider: fos_userbundle main: pattern: ^ / Form_login: Provider: fos_userbundle remember_me: true login_path: / login check_path: / login_check Default_target_path: minn_ads_default_index csrf_provider: form.csrf_provider Remember: key:% secret% access_control: # ... - {path: ^ / api /, role: IS_AUTHENTICATED_FULLY}    

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -