|
| 1 | +<?php namespace App\libs\Auth\Models; |
| 2 | +/** |
| 3 | + * Copyright 2026 OpenStack Foundation |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | + * Unless required by applicable law or agreed to in writing, software |
| 9 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | + * See the License for the specific language governing permissions and |
| 12 | + * limitations under the License. |
| 13 | + **/ |
| 14 | + |
| 15 | +use Auth\User; |
| 16 | +use Doctrine\ORM\Mapping AS ORM; |
| 17 | + |
| 18 | +#[ORM\Table(name: 'two_factor_audit_log')] |
| 19 | +#[ORM\Entity(repositoryClass: \App\Repositories\DoctrineTwoFactorAuditLogRepository::class)] |
| 20 | +class TwoFactorAuditLog |
| 21 | +{ |
| 22 | + public const EventChallengeIssued = 'challenge_issued'; |
| 23 | + public const EventChallengeSucceeded = 'challenge_succeeded'; |
| 24 | + public const EventChallengeFailed = 'challenge_failed'; |
| 25 | + public const EventEnrollmentChanged = 'enrollment_changed'; |
| 26 | + public const EventDeviceTrusted = 'device_trusted'; |
| 27 | + public const EventDeviceRevoked = 'device_revoked'; |
| 28 | + public const EventRecoveryUsed = 'recovery_used'; |
| 29 | + public const EventSettingsChanged = 'settings_changed'; |
| 30 | + |
| 31 | + public const MethodEmailOtp = 'email_otp'; |
| 32 | + public const MethodSmsOtp = 'sms_otp'; |
| 33 | + public const MethodTotp = 'totp'; |
| 34 | + public const MethodPasskey = 'passkey'; |
| 35 | + public const MethodRecovery = 'recovery'; |
| 36 | + |
| 37 | + #[ORM\Id] |
| 38 | + #[ORM\GeneratedValue] |
| 39 | + #[ORM\Column(name: 'id', type: 'integer', unique: true, nullable: false)] |
| 40 | + protected $id; |
| 41 | + |
| 42 | + #[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id', onDelete: 'CASCADE')] |
| 43 | + #[ORM\ManyToOne(targetEntity: \Auth\User::class)] |
| 44 | + private $user; |
| 45 | + |
| 46 | + #[ORM\Column(name: 'event_type', type: 'string', length: 64)] |
| 47 | + private $event_type; |
| 48 | + |
| 49 | + #[ORM\Column(name: 'method', type: 'string', length: 32)] |
| 50 | + private $method; |
| 51 | + |
| 52 | + #[ORM\Column(name: 'ip_address', type: 'string', length: 45)] |
| 53 | + private $ip_address; |
| 54 | + |
| 55 | + #[ORM\Column(name: 'user_agent', type: 'text')] |
| 56 | + private $user_agent; |
| 57 | + |
| 58 | + #[ORM\Column(name: 'metadata', type: 'json', nullable: true)] |
| 59 | + private $metadata; |
| 60 | + |
| 61 | + #[ORM\Column(name: 'created_at', type: 'datetime')] |
| 62 | + private $created_at; |
| 63 | + |
| 64 | + public function __construct() |
| 65 | + { |
| 66 | + $this->created_at = new \DateTime('now', new \DateTimeZone('UTC')); |
| 67 | + $this->metadata = null; |
| 68 | + } |
| 69 | + |
| 70 | + public function getId(): int { return (int) $this->id; } |
| 71 | + |
| 72 | + public function getUser(): User { return $this->user; } |
| 73 | + public function setUser(User $user): void { $this->user = $user; } |
| 74 | + |
| 75 | + public function getEventType(): string { return $this->event_type; } |
| 76 | + public function setEventType(string $value): void { $this->event_type = $value; } |
| 77 | + |
| 78 | + public function getMethod(): string { return $this->method; } |
| 79 | + public function setMethod(string $value): void { $this->method = $value; } |
| 80 | + |
| 81 | + public function getIpAddress(): string { return $this->ip_address; } |
| 82 | + public function setIpAddress(string $value): void { $this->ip_address = $value; } |
| 83 | + |
| 84 | + public function getUserAgent(): string { return $this->user_agent; } |
| 85 | + public function setUserAgent(string $value): void { $this->user_agent = $value; } |
| 86 | + |
| 87 | + public function getMetadata(): ?array { return $this->metadata; } |
| 88 | + public function setMetadata(?array $value): void { $this->metadata = $value; } |
| 89 | + |
| 90 | + public function getCreatedAt(): \DateTime { return $this->created_at; } |
| 91 | + |
| 92 | + public function __get($name) { return $this->{$name}; } |
| 93 | +} |
0 commit comments