TRF Certest first commit

This commit is contained in:
2025-02-26 08:57:46 +01:00
commit 3ce064a108
2524 changed files with 475404 additions and 0 deletions
@@ -0,0 +1,65 @@
<?php
namespace Vanguard\Services\Auth\TwoFactor;
trait Authenticatable
{
/**
* Get the e-mail address used for two-factor authentication.
*/
public function getEmailForTwoFactorAuth(): string
{
return $this->email;
}
/**
* Get the country code used for two-factor authentication.
*/
public function getAuthCountryCode(): string
{
return $this->two_factor_country_code;
}
/**
* Get the phone number used for two-factor authentication.
*/
public function getAuthPhoneNumber(): string
{
return $this->two_factor_phone;
}
/**
* Set the country code and phone number used for two-factor authentication.
*/
public function setAuthPhoneInformation(string $countryCode, string $phoneNumber)
{
$this->two_factor_country_code = $countryCode;
$this->two_factor_phone = $phoneNumber;
}
/**
* Get the two-factor provider options in array format.
*/
public function getTwoFactorAuthProviderOptions(): array
{
return json_decode($this->two_factor_options, true) ?: [];
}
/**
* Set the two-factor provider options in array format.
*/
public function setTwoFactorAuthProviderOptions(array $options): void
{
$this->two_factor_options = json_encode($options);
}
/**
* Determine if the user is using two-factor authentication.
*/
public function getUsingTwoFactorAuthAttribute(): bool
{
$options = $this->getTwoFactorAuthProviderOptions();
return isset($options['id']);
}
}
@@ -0,0 +1,38 @@
<?php
namespace Vanguard\Services\Auth\TwoFactor\Contracts;
use Illuminate\Contracts\Auth\Authenticatable as BaseAuthenticatable;
interface Authenticatable extends BaseAuthenticatable
{
/**
* Get the e-mail address used for two-factor authentication.
*/
public function getEmailForTwoFactorAuth(): string;
/**
* Get the country code used for two-factor authentication.
*/
public function getAuthCountryCode(): string;
/**
* Get the phone number used for two-factor authentication.
*/
public function getAuthPhoneNumber(): string;
/**
* Set the country code and phone number used for two-factor authentication.
*/
public function setAuthPhoneInformation(string $countryCode, string $phoneNumber);
/**
* Get the two-factor provider options in array format.
*/
public function getTwoFactorAuthProviderOptions(): array;
/**
* Set the two-factor provider options in array format.
*/
public function setTwoFactorAuthProviderOptions(array $options): void;
}
@@ -0,0 +1,33 @@
<?php
namespace Vanguard\Services\Auth\TwoFactor\Contracts;
use Vanguard\Services\Auth\TwoFactor\Contracts\Authenticatable as TwoFactorAuthenticatable;
interface Provider
{
/**
* Determine if the given user has two-factor authentication enabled.
*/
public function isEnabled(TwoFactorAuthenticatable $user): bool;
/**
* Register the given user with the provider.
*/
public function register(TwoFactorAuthenticatable $user): void;
/**
* Sends an SMS with a phone verification token.
*/
public function sendTwoFactorVerificationToken(TwoFactorAuthenticatable $user): bool;
/**
* Determine if the given token is valid for the given user.
*/
public function tokenIsValid(TwoFactorAuthenticatable $user, $token): bool;
/**
* Delete the given user from the provider.
*/
public function delete(TwoFactorAuthenticatable $user): void;
}
+14
View File
@@ -0,0 +1,14 @@
<?php
namespace Vanguard\Services\Auth\TwoFactor;
class Facade extends \Illuminate\Support\Facades\Facade
{
/**
* Get the registered name of the component.
*/
protected static function getFacadeAccessor(): string
{
return 'authy';
}
}