简体   繁体   中英

Symfony2 Custom Auth

We're about to embark on building a REST API for a clients web application, and they've specified that users log in with a PIN number (Any length).

So would I go about setting up a Custom Auth Provider, etc, which would find the user by PIN number and if it find's them auth? Is this possible? Most examples I've seen require a username and a password.

Where as I only require a password.

Is this possible with Symfony2, or should I be looking elsewhere?

To answer your first question, the cookbook shows how to create you own custom authentication provider: http://symfony.com/doc/current/cookbook/security/custom_authentication_provider.html

But it's not for the faint of heart. Am I correct in assuming that you have not used Symfony 2 much?

I don't really see why you could not use the existing typical username/password approach in which a pin number serves as both the username as well as the password. You would tweak the login form so it only display the one field. Then somewhere along the way you would put in a bit of code to copy the submitted data into both username and password. Probably easier than trying to make a complete auth system.

Might also search around a bit so see if someone else has already done the work for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM