Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/composer-post-install-script.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function getEnvironment(): string
],
[
'source' => 'vendor/dotkernel/dot-mail/config/mail.global.php.dist',
'destination' => 'config/autoload/mail.global.php',
'destination' => 'config/autoload/mail.local.php',
Comment thread
pinclau marked this conversation as resolved.
'environment' => [ENVIRONMENT_DEVELOPMENT, ENVIRONMENT_PRODUCTION],
],
];
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"laminas/laminas-inputfilter": "^2.31.0",
"laminas/laminas-stdlib": "^3.20.0",
"mezzio/mezzio": "^3.20.1",
"mezzio/mezzio-authentication-oauth2": "^2.11.0",
"mezzio/mezzio-authentication-oauth2": "^3.0.1",
"mezzio/mezzio-authorization-acl": "^1.11.0",
"mezzio/mezzio-authorization-rbac": "^1.8.0",
"mezzio/mezzio-cors": "^1.13.0",
Expand Down
2 changes: 1 addition & 1 deletion src/Admin/src/Service/AdminService.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function saveAdmin(array $data, ?Admin $admin = null): Admin
$admin = new Admin();
}

if (array_key_exists('identity', $data) && $data['identity'] !== null && ! $admin->hasIdentity()) {
if (array_key_exists('identity', $data) && $data['identity'] !== null) {
Comment thread
alexmerlin marked this conversation as resolved.
Outdated
$admin->setIdentity($data['identity']);
}
if (array_key_exists('password', $data) && $data['password'] !== null) {
Expand Down
18 changes: 8 additions & 10 deletions src/Core/src/Admin/src/Entity/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ class Admin extends AbstractEntity implements UserEntityInterface
use TimestampsTrait;
use UuidIdentifierTrait;

/** @var non-empty-string|null $identity */
/** @var non-empty-string $identity */
#[ORM\Column(name: 'identity', type: 'string', length: 191, unique: true)]
protected ?string $identity = null;
protected string $identity;

#[ORM\Column(name: 'firstName', type: 'string', length: 191, nullable: true)]
protected ?string $firstName = null;
Expand All @@ -43,7 +43,7 @@ class Admin extends AbstractEntity implements UserEntityInterface
protected ?string $lastName = null;

#[ORM\Column(name: 'password', type: 'string', length: 191)]
protected ?string $password = null;
protected string $password;

#[ORM\Column(
type: 'admin_status_enum',
Expand Down Expand Up @@ -76,11 +76,6 @@ public function getIdentity(): ?string
return $this->identity;
}

public function hasIdentity(): bool
{
return $this->identity !== null;
}

/**
* @param non-empty-string $identity
*/
Expand Down Expand Up @@ -115,7 +110,7 @@ public function setLastName(string $lastName): self
return $this;
}

public function getPassword(): ?string
public function getPassword(): string
{
return $this->password;
}
Expand Down Expand Up @@ -213,9 +208,12 @@ public function isActive(): bool
return $this->status === AdminStatusEnum::Active;
}

/**
* @return non-empty-string
*/
public function getIdentifier(): string
{
return (string) $this->identity;
return $this->identity;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Core/src/App/src/Entity/NumericIdentifierTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ trait NumericIdentifierTrait
#[ORM\Id]
#[ORM\Column(name: 'id', type: 'integer', options: ['unsigned' => true])]
#[ORM\GeneratedValue(strategy: 'AUTO')]
protected ?int $id;
protected int $id;

public function getId(): ?int
public function getId(): int
{
return $this->id;
}
Expand Down
46 changes: 20 additions & 26 deletions src/Core/src/Security/src/Entity/OAuthAccessToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Lcobucci\JWT\Signer\Key\InMemory;
use Lcobucci\JWT\Signer\Rsa\Sha256;
use Lcobucci\JWT\Token;
use League\OAuth2\Server\CryptKey;
use League\OAuth2\Server\CryptKeyInterface;
use League\OAuth2\Server\Entities\AccessTokenEntityInterface;
use League\OAuth2\Server\Entities\ClientEntityInterface;
use League\OAuth2\Server\Entities\ScopeEntityInterface;
Expand All @@ -33,8 +33,9 @@ class OAuthAccessToken implements AccessTokenEntityInterface
#[ORM\JoinColumn(name: 'client_id', referencedColumnName: 'id')]
private ClientEntityInterface $client;

#[ORM\Column(name: 'user_id', type: 'string', length: 25, nullable: true)]
private ?string $userId = null;
/** @var non-empty-string $userId */
#[ORM\Column(name: 'user_id', type: 'string', length: 25)]
private string $userId;

/** @var non-empty-string $token */
#[ORM\Column(name: 'token', type: 'string', length: 100)]
Expand All @@ -53,7 +54,7 @@ class OAuthAccessToken implements AccessTokenEntityInterface
#[ORM\Column(name: 'expires_at', type: 'datetime_immutable')]
private DateTimeImmutable $expiresAt;

private ?CryptKey $privateKey = null;
private ?CryptKeyInterface $privateKey = null;

private ?Configuration $jwtConfiguration = null;

Expand All @@ -62,11 +63,9 @@ public function __construct()
$this->scopes = new ArrayCollection();
}

public function setClient(ClientEntityInterface $client): self
public function setClient(ClientEntityInterface $client): void
{
$this->client = $client;

return $this;
}

public function getClient(): ClientEntityInterface
Expand All @@ -85,11 +84,9 @@ public function getToken(): string
/**
* @param non-empty-string $token
*/
public function setToken(string $token): self
public function setToken(string $token): void
{
$this->token = $token;

return $this;
}

public function setIsRevoked(bool $isRevoked): self
Expand Down Expand Up @@ -122,37 +119,33 @@ public function getIdentifier(): string
/**
* @param mixed $identifier
*/
public function setIdentifier($identifier): self
public function setIdentifier($identifier): void
{
return $this->setToken($identifier);
$this->setToken($identifier);
}

/**
* @param string|int|null $identifier
* @param non-empty-string|int $identifier
*/
public function setUserIdentifier($identifier): self
public function setUserIdentifier($identifier): void
{
if (is_int($identifier)) {
$identifier = (string) $identifier;
}

$this->userId = $identifier;

return $this;
}

public function getUserIdentifier(): ?string
public function getUserIdentifier(): string
{
return $this->userId;
}

public function addScope(ScopeEntityInterface $scope): self
public function addScope(ScopeEntityInterface $scope): void
{
if (! $this->scopes->contains($scope)) {
$this->scopes->add($scope);
}

return $this;
}

public function removeScope(OAuthScope $scope): self
Expand All @@ -178,18 +171,14 @@ public function getExpiryDateTime(): DateTimeImmutable
return $this->expiresAt;
}

public function setExpiryDateTime(DateTimeImmutable $dateTime): self
public function setExpiryDateTime(DateTimeImmutable $dateTime): void
{
$this->expiresAt = $dateTime;

return $this;
}

public function setPrivateKey(CryptKey $privateKey): self
public function setPrivateKey(CryptKeyInterface $privateKey): void
{
$this->privateKey = $privateKey;

return $this;
}

public function initJwtConfiguration(): self
Expand Down Expand Up @@ -238,4 +227,9 @@ public function __toString(): string
{
return $this->convertToJWT()->toString();
}

public function toString(): string
{
return $this->convertToJWT()->toString();
}
}
20 changes: 7 additions & 13 deletions src/Core/src/Security/src/Entity/OAuthAuthCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,9 @@ public function __construct()
$this->scopes = new ArrayCollection();
}

public function setClient(ClientEntityInterface $client): self
public function setClient(ClientEntityInterface $client): void
{
$this->client = $client;

return $this;
}

public function getClient(): ClientEntityInterface
Expand All @@ -68,19 +66,17 @@ public function getIdentifier(): string
/**
* @param mixed $identifier
*/
public function setIdentifier($identifier): self
public function setIdentifier($identifier): void
{
$this->setId($identifier);

return $this;
}

/**
* @param string|int|null $identifier
*/
public function setUserIdentifier($identifier): self
public function setUserIdentifier($identifier): void
{
return $this;
$this->setIdentifier($identifier);
}

public function getUserIdentifier(): ?string
Expand Down Expand Up @@ -114,13 +110,11 @@ public function revoke(): self
return $this;
}

public function addScope(ScopeEntityInterface $scope): self
public function addScope(ScopeEntityInterface $scope): void
{
if (! $this->scopes->contains($scope)) {
$this->scopes->add($scope);
}

return $this;
}

public function removeScope(ScopeEntityInterface $scope): self
Expand Down Expand Up @@ -156,8 +150,8 @@ public function getExpiryDateTime(): DateTimeImmutable
return $this->getExpiresDatetime();
}

public function setExpiryDateTime(DateTimeImmutable $dateTime): self
public function setExpiryDateTime(DateTimeImmutable $dateTime): void
{
return $this->setExpiresDatetime($dateTime);
$this->setExpiresDatetime($dateTime);
}
}
14 changes: 11 additions & 3 deletions src/Core/src/Security/src/Entity/OAuthClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ class OAuthClient implements ClientEntityInterface
{
use NumericIdentifierTrait;

public const NAME_ADMIN = 'admin';
public const NAME_FRONTEND = 'frontend';
public const string NAME_ADMIN = 'admin';
public const string NAME_FRONTEND = 'frontend';

#[ORM\ManyToOne(targetEntity: User::class)]
#[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id', nullable: true)]
private ?User $user = null;

/** @var non-empty-string */
#[ORM\Column(name: 'name', type: 'string', length: 40)]
private string $name;

Expand Down Expand Up @@ -55,18 +56,25 @@ public function getIdentity(): string
return $this->getName();
}

/**
* @return non-empty-string
*/
public function getIdentifier(): string
{
return $this->getName();
}

/** @param non-empty-string $name */
public function setName(string $name): self
{
$this->name = $name;

return $this;
}

/**
* @return non-empty-string
*/
public function getName(): string
{
return $this->name;
Expand Down Expand Up @@ -96,7 +104,7 @@ public function getRedirect(): string
return $this->redirect;
}

public function getRedirectUri(): ?string
public function getRedirectUri(): string
{
return $this->getRedirect();
}
Expand Down
11 changes: 3 additions & 8 deletions src/Core/src/Security/src/Entity/OAuthRefreshToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,13 @@ public function getIdentifier(): string
return (string) $this->getId();
}

public function setIdentifier(mixed $identifier): self
public function setIdentifier(mixed $identifier): void
{
return $this;
}

public function setAccessToken(AccessTokenEntityInterface $accessToken): self
public function setAccessToken(AccessTokenEntityInterface $accessToken): void
{
$this->accessToken = $accessToken;

return $this;
}

public function getAccessToken(): OAuthAccessToken|AccessTokenEntityInterface
Expand Down Expand Up @@ -73,10 +70,8 @@ public function getExpiryDateTime(): DateTimeImmutable
return $this->expiresAt;
}

public function setExpiryDateTime(DateTimeImmutable $dateTime): self
public function setExpiryDateTime(DateTimeImmutable $dateTime): void
{
$this->expiresAt = $dateTime;

return $this;
}
}
Loading
Loading