Skip to content

Commit

Permalink
Fixes on security
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenvdlinde committed Feb 21, 2020
1 parent 1e25de0 commit 2896646
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 12 deletions.
9 changes: 8 additions & 1 deletion api/config/packages/security.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
security:
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
providers:
in_memory: { memory: ~ }
chain_provider:
chain:
providers: [CommongroundApplicationProvider, CommongroundUserProvider]
commongroundUserProvider:
id: App\Security\User\CommongroundUserProvider
commongroundApplicationProvider:
id: App\Security\User\CommongroundApplicationProvider
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
Expand All @@ -12,6 +18,7 @@ security:
pattern: ^/$
methods: [GET]
main:
provider: chain_provider
guard:
authenticators:
- App\Security\CommongroundApplicationAuthenticator
Expand Down
2 changes: 1 addition & 1 deletion api/public/schema/publiccode.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ url: "https://github.com/ConductionNL/Proto-component-commonground"
landingURL: "test.conduction.nl"
isBasedOn: "https://github.com/ConductionNL/Proto-component-commonground.git"
softwareVersion: "V.0.1"
releaseDate: "2020-19-02"
releaseDate: "2020-20-02"
logo: pc.zaakonline.nl
monochromeLogo: img/logo-mono.svg

Expand Down
2 changes: 1 addition & 1 deletion api/src/Security/User/CommongroundApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class CommongroundApplication implements UserInterface, EquatableInterface
private $salt;
private $roles;

public function __construct($username, $password, $salt, array $roles)
public function __construct(string $username = '', string $password = '', string $salt = null, array $roles = [])
{
$this->username = $username;
$this->password = $password;
Expand Down
8 changes: 4 additions & 4 deletions api/src/Security/User/CommongroundApplicationProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ private function fetchUser($uuid)
// $userData = ...
// pretend it returns an array on success, false if there is no user

if ($userData) {
$password = '...';
//if ($userData) {
// $password = '...';

// ...

return new CommongroundApplication($username, $password, $salt, $roles);
}
return new CommongroundApplication('Default Application', $uuid, null, ['user']);
//}

throw new UsernameNotFoundException(
sprintf('Application "%s" does not exist.', $uuid)
Expand Down
2 changes: 1 addition & 1 deletion api/src/Security/User/CommongroundUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class CommongroundUser implements UserInterface, EquatableInterface
private $salt;
private $roles;

public function __construct($username, $password, $salt, array $roles)
public function __construct(string $username = '', string $password = '', string $salt = null, array $roles = [])
{
$this->username = $username;
$this->password = $password;
Expand Down
8 changes: 4 additions & 4 deletions api/src/Security/User/CommongroundUserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ private function fetchUser($uuid)
//$userData = ...
// pretend it returns an array on success, false if there is no user

if ($userData) {
$password = '...';
//if ($userData) {
// $password = '...';

// ...

return new CommongroundUser($username, $password, $salt, $roles);
}
return new CommongroundUser('Default User', $uuid, null, ['user']);
//}

throw new UsernameNotFoundException(
sprintf('User "%s" does not exist.', $uuid)
Expand Down

0 comments on commit 2896646

Please sign in to comment.