Symfony2 plugin for links CSRF protection - symfony

Is there any plugin that works this way? I've found KnpRadBundle, but i got working project and adjusting it to a new framework would be very long and unnessesary. Do anybody knows such a plugin?
In KnpRadBundle it's exactly this function: https://github.com/KnpLabs/KnpRadBundle/wiki/csrf-protected-links
PS. I'm using Symfony 2.2

I had the exact same problem and found this pull request which solves it.
Using the csrf_token('your_intention') function you can generate a CSRF token in your Twig template. Later you can check the token using the form.csrf_provider service as described in the pull request.

Related

How do I auto sign in to Laravel via an API coming from .net?

We have a portal built in asp.net and we need one of the sections to be an embedded frame containing a webapp built in Laravel, however the Laravel webapp has a login and we dont want users having to login twice. So how do I set this up? I understand I need to use this method :
https://laravel.com/docs/5.4/authentication#authenticating-users
The request would be coming from .net and I would parse say the JSON response, but how do I setup laravel to consume that API call? I have never done anything like this before and I dont know where to start. Can someone explain or give me a series of steps? Thank you!
if you have the user id as $id, you can use:
Auth::loginUsingId($id);

Trying to connect to Facebook through the API

I am trying to connect to Facebook through the API but it is giving me an error of Type:
FacebookUser is not defined in vb file.
I have tried with namespaces but it is not working.
what should I do?
Make sure FacebookUser.api is inside the handler. If possible to post part of code would be better to identify the issue.

How does Spring work with apparently no code?

I am trying to understand the example described here.
What is puzzling to me is that there is apparently no code. I run the spring-security-samples-insecuremvc-3.2.x within Tomcat and a form is presented to interact with but there is no Java code whatsoever as far as I can see. I can't even find the form. I realize that the code must be in one of the dependencies but I am baffled at how this all works.
Spring does generate/provide a default login form if it's configured to do form-based login and no custom login form is configured.
Sidenote: how to create and configure a custom login form is, for example, explained here: http://docs.spring.io/spring-security/site/docs/3.2.x/guides/form.html (to long to be copy/pasted here).
I have been looking at this sample today with the same questions as you - where the heck is the source? I finally found the answer I think you're looking for. Take a look at the pom.xml and in the dependencies you'll see spring-security-samples-messages-jc. Assuming you downloaded all the samples, import that project into STS and you'll find the files you're looking for.
BTW, I've been following the instructions on the spring security website to add security to this sample and I have not yet been able to get it to work - the login screen does not appear. Let me know if you have better luck than me.
The default spring security login form is generated by the class org.springframework.security.web.ui.DefaultLoginPageGeneratingFilter which is in spring-security-web-$version.jar
The method is generateLoginPageHtml()

FOSUserbundle and multiple database connections in Symfony2

I am working on a Symfony2 Application that uses multiple databases. I followed this guide: https://stackoverflow.com/a/24585284/5244717 so now all my routes have a prefix with the database name from where the application should get its data.
But now I need to be able to login, I tried using the FOSUserbundle, but I cannot get FOSUserbundle to work with the company prefix. I added this to the config/routing.yml
fos_user_security:
resource: "#FOSUserBundle/Resources/config/routing/security.xml"
prefix: /{_site}
defaults:
_site: default
Now when I go to http://localhost/company/login it shows me the login form, but when I login it gives me this error:
You must configure the check path to be handled by the firewall using form_login in your security firewall configuration.
I have no idea how to fix this and if the FOSUserbundle will even work with what I am trying to do here. Having used Symfony2 only for week is not really helping. I've been searching the internet for a good solution to using multiple databases in 1 symfony bundle but so far have had little success. Each company should get a separate database with the same structure, but this seems to be an impossible thing to code in Symfony2(or any other framework).
Any help is very much appreciated!
Your options but not limited to
1). have multiple firewalls
2). use of subdomains instead of slugs in url
i could be wrong but i believe symfony does not allow parameters to be set in a route for a login page

A simple GET with Grails

I have built a simple Grails app, with a domain-class and its controller (with the default scaffold functionality).
I want to use this for an Android app.
I had to get my objects in the JSON format, and thanks to stackoverflow it's been easy ;)
Now I have to put data. I should make a POST call to http://localhost:8080/MyApp/person/save with parameters, I suppose. But I can't succeed using RESTClient or other simple utilities/firefox addons that GET/POST data over an HTTP server.
The response web page is an error web page, saying "Property 'name' can't be null" or similar... as if I have no parameters passed. Perhaps I'm not able to make a POST request on a page?! o_O
And how can I enable GET, in Grails, to insert objects?
Thank you.
Funny, I think I am about 2 weeks ahead of you on a similar project. :)
When you do your Post, be sure and include the ?format=json on the end of your URL and grails will automagically parse the params with no extra code in the controller. Isn't grails wonderful?

Resources