-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* symfony security
- Loading branch information
Showing
24 changed files
with
657 additions
and
672 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use BikeShare\App\Security\TokenProvider; | ||
use BikeShare\App\Security\UserProvider; | ||
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface; | ||
use Symfony\Config\SecurityConfig; | ||
|
||
return function (SecurityConfig $security) { | ||
$security | ||
->passwordHasher(PasswordAuthenticatedUserInterface::class) | ||
->algorithm('sha512') | ||
->encodeAsBase64(false) | ||
->iterations(1); | ||
|
||
$security | ||
->provider('app_user_provider') | ||
->id(UserProvider::class); | ||
|
||
$security | ||
->firewall('dev') | ||
->pattern('^/(_(profiler|wdt)|css|images|js)/') | ||
->security(false); | ||
|
||
$mainFirewall = $security->firewall('main'); | ||
$mainFirewall->anonymous(); | ||
$mainFirewall | ||
->formLogin() | ||
->loginPath('login') | ||
->checkPath('login'); | ||
$mainFirewall | ||
->logout() | ||
->path('logout') | ||
->target('/'); | ||
$mainFirewall | ||
->rememberMe() | ||
->secret('%kernel.secret%') | ||
->lifetime(604800) // 1 week in seconds | ||
->tokenProvider( | ||
[ | ||
'service' => TokenProvider::class, | ||
] | ||
); | ||
|
||
$security | ||
->accessControl() | ||
->path('^/login$') | ||
->roles(['IS_AUTHENTICATED_ANONYMOUSLY']); | ||
$security | ||
->accessControl() | ||
->path('^/(sms/)?receive.php$') | ||
->roles(['IS_AUTHENTICATED_ANONYMOUSLY']); | ||
$security | ||
->accessControl() | ||
->path('^/register.php$') | ||
->roles(['IS_AUTHENTICATED_ANONYMOUSLY']); | ||
$security | ||
->accessControl() | ||
->path('^/agree.php$') | ||
->roles(['IS_AUTHENTICATED_ANONYMOUSLY']); | ||
$security | ||
->accessControl() | ||
->path('^/resetPassword$') | ||
->roles(['IS_AUTHENTICATED_ANONYMOUSLY']); | ||
|
||
$security | ||
->accessControl() | ||
->path('^/') | ||
->roles(['ROLE_USER']); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BikeShare\App\Entity; | ||
|
||
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface; | ||
use Symfony\Component\Security\Core\User\UserInterface; | ||
|
||
class User implements UserInterface, PasswordAuthenticatedUserInterface | ||
{ | ||
private int $userId; | ||
private string $number; | ||
private string $password; | ||
private string $city; | ||
private string $userName; | ||
private int $privileges; | ||
|
||
public function __construct( | ||
int $userId, | ||
string $number, | ||
string $email, | ||
string $password, | ||
string $city, | ||
string $userName, | ||
int $privileges | ||
) { | ||
$this->userId = $userId; | ||
$this->number = $number; | ||
$this->email = $email; | ||
$this->password = $password; | ||
$this->city = $city; | ||
$this->userName = $userName; | ||
$this->privileges = $privileges; | ||
} | ||
|
||
public function getCity(): string | ||
{ | ||
return $this->city; | ||
} | ||
|
||
public function getNumber(): string | ||
{ | ||
return $this->number; | ||
} | ||
|
||
public function getEmail(): string | ||
{ | ||
return $this->email; | ||
} | ||
|
||
public function getPrivileges(): int | ||
{ | ||
return $this->privileges; | ||
} | ||
|
||
public function getUserId(): int | ||
{ | ||
return $this->userId; | ||
} | ||
|
||
public function getUsername(): string | ||
{ | ||
return $this->userName; | ||
} | ||
|
||
public function getPassword(): string | ||
{ | ||
return $this->password; | ||
} | ||
|
||
public function getUserIdentifier(): string | ||
{ | ||
return $this->number; | ||
} | ||
|
||
public function getRoles(): array | ||
{ | ||
return ['ROLE_USER']; | ||
} | ||
|
||
public function getSalt(): ?string | ||
{ | ||
return null; | ||
} | ||
|
||
public function eraseCredentials() | ||
{ | ||
// If you store any temporary, sensitive data on the user, clear it here | ||
} | ||
} |
Oops, something went wrong.