2026-05-14 04:30:12 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace App\Domain\Auth;
|
|
|
|
|
|
|
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
|
use Symfony\Component\Uid\Uuid;
|
|
|
|
|
|
|
|
|
|
#[ORM\Entity]
|
|
|
|
|
#[ORM\Table(name: 'api_keys', schema: 'app')]
|
|
|
|
|
class ApiKey
|
|
|
|
|
{
|
|
|
|
|
#[ORM\Id]
|
|
|
|
|
#[ORM\Column(type: 'uuid')]
|
|
|
|
|
private Uuid $id;
|
|
|
|
|
|
|
|
|
|
#[ORM\ManyToOne(targetEntity: User::class)]
|
|
|
|
|
#[ORM\JoinColumn(nullable: false)]
|
|
|
|
|
private User $user;
|
|
|
|
|
|
|
|
|
|
#[ORM\Column(type: 'string', length: 255)]
|
|
|
|
|
private string $label;
|
|
|
|
|
|
feat: admin panel, Mistral client, attribute management, API key command
- Fix EasyAdmin 5 routing: #[AdminDashboard] attribute + easyadmin.routes loader
- Fix login: _username/_password field names, CSRF stateless token config,
sessions directory, Opcache reload after cache:clear
- Add MistralClient behind OllamaClientInterface — switchable via services.yaml alias
- Add Attribute CRUD with EnumType form + ChoiceField display (enum-safe rendering)
- Add Article Type CRUD with AssociationField for attribute assignments
- Add app:api-keys:create console command (bcrypt-hashed, never stored as plaintext)
- Add redis ext to Docker image + symfony/redis-messenger, start workers
- Translate all UI strings to English
- Add tests: MistralClient, ApiKey, CreateApiKeyCommand, StringArrayType,
ArticleTypeCrudController, AttributeDefinitionCrudController (82 tests total)
- Update design doc: tech stack, AI backend switching guide, ops section
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-17 20:15:13 +00:00
|
|
|
#[ORM\Column(type: 'string', length: 8)]
|
|
|
|
|
private string $keyPrefix;
|
|
|
|
|
|
2026-05-14 04:30:12 +00:00
|
|
|
#[ORM\Column(type: 'string', length: 255, unique: true)]
|
|
|
|
|
private string $keyHash;
|
|
|
|
|
|
|
|
|
|
/** @var array<string, bool> */
|
|
|
|
|
#[ORM\Column(type: 'json')]
|
|
|
|
|
private array $permissions = [];
|
|
|
|
|
|
|
|
|
|
#[ORM\Column(type: 'boolean')]
|
|
|
|
|
private bool $isActive = true;
|
|
|
|
|
|
|
|
|
|
#[ORM\Column(type: 'datetime_immutable', nullable: true)]
|
|
|
|
|
private ?\DateTimeImmutable $lastUsedAt = null;
|
|
|
|
|
|
|
|
|
|
#[ORM\Column(type: 'datetime_immutable', nullable: true)]
|
|
|
|
|
private ?\DateTimeImmutable $expiresAt = null;
|
|
|
|
|
|
feat: admin panel, Mistral client, attribute management, API key command
- Fix EasyAdmin 5 routing: #[AdminDashboard] attribute + easyadmin.routes loader
- Fix login: _username/_password field names, CSRF stateless token config,
sessions directory, Opcache reload after cache:clear
- Add MistralClient behind OllamaClientInterface — switchable via services.yaml alias
- Add Attribute CRUD with EnumType form + ChoiceField display (enum-safe rendering)
- Add Article Type CRUD with AssociationField for attribute assignments
- Add app:api-keys:create console command (bcrypt-hashed, never stored as plaintext)
- Add redis ext to Docker image + symfony/redis-messenger, start workers
- Translate all UI strings to English
- Add tests: MistralClient, ApiKey, CreateApiKeyCommand, StringArrayType,
ArticleTypeCrudController, AttributeDefinitionCrudController (82 tests total)
- Update design doc: tech stack, AI backend switching guide, ops section
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-17 20:15:13 +00:00
|
|
|
public function __construct(User $user, string $label, string $keyPrefix, string $keyHash)
|
2026-05-14 04:30:12 +00:00
|
|
|
{
|
|
|
|
|
$this->id = Uuid::v7();
|
|
|
|
|
$this->user = $user;
|
|
|
|
|
$this->label = $label;
|
feat: admin panel, Mistral client, attribute management, API key command
- Fix EasyAdmin 5 routing: #[AdminDashboard] attribute + easyadmin.routes loader
- Fix login: _username/_password field names, CSRF stateless token config,
sessions directory, Opcache reload after cache:clear
- Add MistralClient behind OllamaClientInterface — switchable via services.yaml alias
- Add Attribute CRUD with EnumType form + ChoiceField display (enum-safe rendering)
- Add Article Type CRUD with AssociationField for attribute assignments
- Add app:api-keys:create console command (bcrypt-hashed, never stored as plaintext)
- Add redis ext to Docker image + symfony/redis-messenger, start workers
- Translate all UI strings to English
- Add tests: MistralClient, ApiKey, CreateApiKeyCommand, StringArrayType,
ArticleTypeCrudController, AttributeDefinitionCrudController (82 tests total)
- Update design doc: tech stack, AI backend switching guide, ops section
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-17 20:15:13 +00:00
|
|
|
$this->keyPrefix = $keyPrefix;
|
2026-05-14 04:30:12 +00:00
|
|
|
$this->keyHash = $keyHash;
|
|
|
|
|
}
|
|
|
|
|
|
feat: implement Plan 2 — Article Management API
- 6 new domain repository interfaces (StoragePath, ArticlePhoto, AttributeValue, ChannelField, ArticleTypePlatformConfig, AttributeMapping)
- 6 Doctrine repository implementations
- StorageManager with multi-path quota-aware file storage (LocalStorageManager)
- Application services: ArticleTypeService, ArticleService, ArticleValidator, PhotoService, PlatformService, MappingService
- REST controllers: ArticleType, Article, Photo, Platform, Mapping (all under /api prefix)
- inventory_number sequence migration
- 22 unit tests passing, PHPStan level 9 clean, CS Fixer clean
- Fixed phpdoc_to_comment CS Fixer rule (disabled) to preserve @var type annotations
- Fixed PHPStan: User::getUserIdentifier non-empty-string, AIPipelineJob nullable missingFields
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 05:19:20 +00:00
|
|
|
public function getId(): Uuid
|
|
|
|
|
{
|
|
|
|
|
return $this->id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getUser(): User
|
|
|
|
|
{
|
|
|
|
|
return $this->user;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getLabel(): string
|
|
|
|
|
{
|
|
|
|
|
return $this->label;
|
|
|
|
|
}
|
|
|
|
|
|
feat: admin panel, Mistral client, attribute management, API key command
- Fix EasyAdmin 5 routing: #[AdminDashboard] attribute + easyadmin.routes loader
- Fix login: _username/_password field names, CSRF stateless token config,
sessions directory, Opcache reload after cache:clear
- Add MistralClient behind OllamaClientInterface — switchable via services.yaml alias
- Add Attribute CRUD with EnumType form + ChoiceField display (enum-safe rendering)
- Add Article Type CRUD with AssociationField for attribute assignments
- Add app:api-keys:create console command (bcrypt-hashed, never stored as plaintext)
- Add redis ext to Docker image + symfony/redis-messenger, start workers
- Translate all UI strings to English
- Add tests: MistralClient, ApiKey, CreateApiKeyCommand, StringArrayType,
ArticleTypeCrudController, AttributeDefinitionCrudController (82 tests total)
- Update design doc: tech stack, AI backend switching guide, ops section
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-17 20:15:13 +00:00
|
|
|
public function getKeyPrefix(): string
|
|
|
|
|
{
|
|
|
|
|
return $this->keyPrefix;
|
|
|
|
|
}
|
|
|
|
|
|
feat: implement Plan 2 — Article Management API
- 6 new domain repository interfaces (StoragePath, ArticlePhoto, AttributeValue, ChannelField, ArticleTypePlatformConfig, AttributeMapping)
- 6 Doctrine repository implementations
- StorageManager with multi-path quota-aware file storage (LocalStorageManager)
- Application services: ArticleTypeService, ArticleService, ArticleValidator, PhotoService, PlatformService, MappingService
- REST controllers: ArticleType, Article, Photo, Platform, Mapping (all under /api prefix)
- inventory_number sequence migration
- 22 unit tests passing, PHPStan level 9 clean, CS Fixer clean
- Fixed phpdoc_to_comment CS Fixer rule (disabled) to preserve @var type annotations
- Fixed PHPStan: User::getUserIdentifier non-empty-string, AIPipelineJob nullable missingFields
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 05:19:20 +00:00
|
|
|
public function getKeyHash(): string
|
|
|
|
|
{
|
|
|
|
|
return $this->keyHash;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function isActive(): bool
|
|
|
|
|
{
|
|
|
|
|
return $this->isActive;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setIsActive(bool $active): void
|
|
|
|
|
{
|
|
|
|
|
$this->isActive = $active;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getLastUsedAt(): ?\DateTimeImmutable
|
|
|
|
|
{
|
|
|
|
|
return $this->lastUsedAt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getExpiresAt(): ?\DateTimeImmutable
|
|
|
|
|
{
|
|
|
|
|
return $this->expiresAt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setExpiresAt(?\DateTimeImmutable $expiresAt): void
|
|
|
|
|
{
|
|
|
|
|
$this->expiresAt = $expiresAt;
|
|
|
|
|
}
|
2026-05-14 04:30:12 +00:00
|
|
|
|
|
|
|
|
/** @return array<string, bool> */
|
feat: implement Plan 2 — Article Management API
- 6 new domain repository interfaces (StoragePath, ArticlePhoto, AttributeValue, ChannelField, ArticleTypePlatformConfig, AttributeMapping)
- 6 Doctrine repository implementations
- StorageManager with multi-path quota-aware file storage (LocalStorageManager)
- Application services: ArticleTypeService, ArticleService, ArticleValidator, PhotoService, PlatformService, MappingService
- REST controllers: ArticleType, Article, Photo, Platform, Mapping (all under /api prefix)
- inventory_number sequence migration
- 22 unit tests passing, PHPStan level 9 clean, CS Fixer clean
- Fixed phpdoc_to_comment CS Fixer rule (disabled) to preserve @var type annotations
- Fixed PHPStan: User::getUserIdentifier non-empty-string, AIPipelineJob nullable missingFields
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 05:19:20 +00:00
|
|
|
public function getPermissions(): array
|
|
|
|
|
{
|
|
|
|
|
return $this->permissions;
|
|
|
|
|
}
|
2026-05-14 04:30:12 +00:00
|
|
|
|
|
|
|
|
public function hasPermission(string $permission): bool
|
|
|
|
|
{
|
|
|
|
|
return $this->permissions[$permission] ?? false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function grantPermission(string $permission): void
|
|
|
|
|
{
|
|
|
|
|
$this->permissions[$permission] = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function markUsed(): void
|
|
|
|
|
{
|
|
|
|
|
$this->lastUsedAt = new \DateTimeImmutable();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function isExpired(): bool
|
|
|
|
|
{
|
|
|
|
|
return null !== $this->expiresAt && $this->expiresAt < new \DateTimeImmutable();
|
|
|
|
|
}
|
|
|
|
|
}
|