Skip to content

Cookbook article: Authenticating against an external API #2358

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

Closed
weaverryan opened this issue Mar 26, 2013 · 10 comments
Closed

Cookbook article: Authenticating against an external API #2358

weaverryan opened this issue Mar 26, 2013 · 10 comments
Labels
actionable Clear and specific issues ready for anyone to take them. Security

Comments

@weaverryan
Copy link
Member

This is a question that comes up quite frequently: how to setup a custom authentication system where the username/password are checked in the background against an API. In this case, things in the normal flow like UserProvider::loadUserByUsername don't make sense.

I think it may be useful to have a second cookbook entry (in addition to custom_authentication_provider, which talks about WSSE) for this use-case. The "custom-authentication" world is big and varied - if we added this, it would serve to cover more common, but difficult use cases.

@romaricdrigon
Copy link
Contributor

This is tricky.

On the one hand, we need to check the password. The AuthenticationProvider is the place for this, we can not just implement a UserProvider proxying an external service as it's obviously not gonna give you this information.

On the other hand, without an UserProvider, we may be running issues when refreshUser will be called.

What would be the use cases of this cookbook article?
In my experience, when dealing with services such as OpenID, you create an OpenIDIdentity object linked to your users and it's that entity that go through a specific workflow. You still need to have an User entity in your "Symfony2", in your application, as rarely you get enough informations from external service nor when to pollute it with application-specific details.

@weaverryan
Copy link
Member Author

I think we can and should handle this in #3357. Since I'm the one who opened this issue, I'm going to close it now and hope that we handle it well there. @romaricdrigon since you've been working on some security stuff, if you have some time to look at the implementation in #3357, I'd love your thoughts :).

Cheers!

@skobkin
Copy link

skobkin commented Mar 28, 2015

Did it cover things like OpenID? I didn't found any cookbook entries which can help to do some types of authentication similar to the OpenID (redirect from login form and then check some credentials when user returned back to the login check route from extenal API).

@romaricdrigon
Copy link
Contributor

The closest thing to using an external API would be this article : http://symfony.com/doc/current/cookbook/security/custom_authentication_provider.html

Basically this is this + handling redirection/responses in the firewall. Last time I had to implement such a thing, I looked a lot to similar OAuth or OpenID bundles. Also I'm not sure if there are no way to simplify this with 2.4+ Security component, at that time I had to use 2.3 LTS.

However, I'm wondering if we should cover this in the documentation. I feel like it's pretty advanced and we would be going way further than the other articles. Implementing this requires understanding a lot of subsystems, and the debug during implementation is usually tricky.

@romaricdrigon
Copy link
Contributor

Is there still some interest for that cookbook entry?
I thought about it, if still relevant I may work on it next days.

@skobkin
Copy link

skobkin commented Apr 1, 2015

@romaricdrigon, Yes! I will be very grateful if you do it.
Meanwhile I began to understand how to do it, but I'm new to the Symfony and I will check and correct my own unfinished code considering your article if it will be written.
Also I think I'm not alone with this kind of problem and your cookbook entry may be very helpful to many newbies in the Symfony community.

@pawelkolanowski
Copy link

@romaricdrigon +1

1 similar comment
@damijanc
Copy link

damijanc commented Jun 9, 2015

@romaricdrigon +1

@nmoreaud
Copy link

+1, still wondering how to do this...

@chakiri
Copy link

chakiri commented Jun 28, 2018

@romaricdrigon + 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
actionable Clear and specific issues ready for anyone to take them. Security
Projects
None yet
Development

No branches or pull requests

7 participants