Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shield-wall/simple-authenticator
https://github.com/shield-wall/simple-authenticator
authentication login php symfony symfony-bundle
Last synced: 5 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/shield-wall/simple-authenticator
- Owner: shield-wall
- License: mit
- Created: 2022-07-09T13:36:28.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-08-26T15:38:55.000Z (about 2 years ago)
- Last Synced: 2024-04-10T11:22:36.030Z (7 months ago)
- Topics: authentication, login, php, symfony, symfony-bundle
- Language: PHP
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Simple authenticator
====================It's a simple symfony authenticator, for you be able to log in just with email.
### Install
```shell
composer req shield-w4ll/simple-authenticator
```> **Note**
> We relly recommend use this package in **dev environment** only.### Configuration
```yaml
#config/packages/shield_wall.yaml
when@dev:
simple_authenticator:
route:
redirect_success: 'profile_edit'
redirect_failure: 'app_login'security:
firewalls:
main:
custom_authenticators:
- ShieldWall\SimpleAuthenticator\Security\EmailAuthenticator
``````yaml
#config/routes/shield_wall.yaml
simple_authenticator_login:
prefix: ^/
path: /simple_authenticator/login
```
```yaml
#config/service.yaml
ShieldWall\SimpleAuthenticator\Security\EmailAuthenticator:
arguments:
- '@Symfony\Component\Routing\Generator\UrlGeneratorInterface'
- '@App\Repository\UserRepository'
- '%shield_wall.simple_authenticator.route.redirect_success%'
- '%shield_wall.simple_authenticator.route.redirect_failure%'
```
```php
//YourController.php
public function yourAction()
{
$simpleAuthenticatorForm = $this->createForm(SimpleAuthenticatorType::class, null, [
'action' => $this->generateUrl('simple_authenticator_login'),
]);
$simpleAuthenticatorFromView = $simpleAuthenticatorForm->createView();return $this->render('your_template.html.twig', [
'simpleAuthenticatorFrom' => $simpleAuthenticatorFromView,
]);
}//your_file.html.twig
{{ form(simpleAuthenticatorFrom) }}
```Repository
```php
//src/Repository/UserRepository.php
class UserRepository extends ServiceEntityRepository implements EmailRepositoryInterface
{
public function findOneByEmail(string $email): UserInterface
{
return $this->findOneBy(['email' => $email]);
}
}```
TODO
- need to see someway to get the route name from controller `simple_authenticator_login`
- import route as resource
- service should be declared automatically.