Skip to content

Commit

Permalink
Annotate classes with @final/@internal
Browse files Browse the repository at this point in the history
  • Loading branch information
scheb committed Dec 31, 2020
1 parent 5291136 commit cc7028a
Show file tree
Hide file tree
Showing 77 changed files with 237 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
use Scheb\TwoFactorBundle\Security\TwoFactor\Provider\PreparationRecorderInterface;
use Symfony\Component\Security\Http\Event\CheckPassportEvent;

/**
* @final
*/
class CheckBackupCodeListener extends AbstractCheckCodeListener
{
// Must be called before CheckTwoFactorCodeListener, because CheckTwoFactorCodeListener will throw an exception
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
use Scheb\TwoFactorBundle\Model\BackupCodeInterface;
use Scheb\TwoFactorBundle\Model\PersisterInterface;

/**
* @final
*/
class BackupCodeManager implements BackupCodeManagerInterface
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace Scheb\TwoFactorBundle\Security\TwoFactor\Backup;

/**
* @final
*/
class NullBackupCodeManager implements BackupCodeManagerInterface
{
public function isBackupCode($user, string $code): bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*
* Compatibility for Symfony <= 5.1, from Symfony 5.2 on the bundle uses FirewallListenerFactoryInterface
* to inject its TwoFactorAccessListener.
*
* @final
*/
class AccessListenerCompilerPass implements CompilerPassInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

/**
* Get all registered authentication providers and decorate them with AuthenticationProviderDecorator.
*
* @final
*/
class AuthenticationProviderDecoratorCompilerPass implements CompilerPassInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

/**
* Determine the default mailer to use.
*
* @final
*/
class MailerCompilerPass implements CompilerPassInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
/**
* Decorates all remember-me services instances so that the remember-me cookie doesn't leak when two-factor
* authentication is required.
*
* @final
*/
class RememberMeServicesDecoratorCompilerPass implements CompilerPassInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

/**
* Collect registered two-factor firewall configs and add them to the context.
*
* @final
*/
class TwoFactorFirewallConfigCompilerPass implements CompilerPassInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

/**
* Collect registered two-factor providers and register them.
*
* @final
*/
class TwoFactorProviderCompilerPass implements CompilerPassInterface
{
Expand Down
3 changes: 3 additions & 0 deletions src/bundle/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
use Symfony\Component\Security\Guard\Token\PostAuthenticationGuardToken;
use Symfony\Component\Security\Http\Authenticator\Token\PostAuthenticationToken;

/**
* @final
*/
class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder(): TreeBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AuthenticatorFactoryInterface;

// Compatibility with authenticators in Symfony >= 5.1
/**
* @internal Compatibility with authenticators in Symfony >= 5.1
*/
class AuthenticatorTwoFactorFactory extends TwoFactorFactory implements AuthenticatorFactoryInterface
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\FirewallListenerFactoryInterface as BaseFirewallListenerFactoryInterface;

if (interface_exists(BaseFirewallListenerFactoryInterface::class)) {
// Compatibility for Symfony >= 5.2
/**
* @internal Compatibility for Symfony >= 5.2
*/
interface FirewallListenerFactoryInterface extends BaseFirewallListenerFactoryInterface
{
}
} else {
// Compatibility for Symfony <= 5.1
/**
* @internal Compatibility for Symfony <= 5.1
*/
interface FirewallListenerFactoryInterface
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\Security\Http\Event\AuthenticationTokenCreatedEvent;

/**
* @internal Technically this class is final, but the compatibility layer needs to extend it
*/
class TwoFactorFactory implements SecurityFactoryInterface, FirewallListenerFactoryInterface
{
public const AUTHENTICATION_PROVIDER_KEY = 'two_factor';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;

/**
* @final
*
* @internal Helper class for TwoFactorFactory only
*/
class TwoFactorServicesFactory
{
public function createSuccessHandler(ContainerBuilder $container, string $firewallName, array $config, string $twoFactorFirewallConfigId): string
Expand Down
3 changes: 3 additions & 0 deletions src/bundle/DependencyInjection/SchebTwoFactorExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

/**
* @final
*/
class SchebTwoFactorExtension extends Extension
{
public function load(array $configs, ContainerBuilder $container): void
Expand Down
3 changes: 3 additions & 0 deletions src/bundle/Model/Persister/DoctrinePersister.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
use Doctrine\Persistence\ObjectManager;
use Scheb\TwoFactorBundle\Model\PersisterInterface;

/**
* @final
*/
class DoctrinePersister implements PersisterInterface
{
/**
Expand Down
5 changes: 5 additions & 0 deletions src/bundle/Model/Persister/DoctrinePersisterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
use Doctrine\Persistence\ManagerRegistry;
use Scheb\TwoFactorBundle\Model\PersisterInterface;

/**
* @final
*
* @internal For the DIC to construct a DoctrinePersister instance
*/
class DoctrinePersisterFactory
{
/**
Expand Down
3 changes: 3 additions & 0 deletions src/bundle/SchebTwoFactorBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;

/**
* @final
*/
class SchebTwoFactorBundle extends Bundle
{
public function build(ContainerBuilder $container): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;

/**
* @final
*/
class AuthenticationTrustResolver implements AuthenticationTrustResolverInterface
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

use Symfony\Component\Security\Core\Exception\BadCredentialsException;

/**
* @final
*/
class InvalidTwoFactorCodeException extends BadCredentialsException
{
public const MESSAGE = 'Invalid two-factor authentication code.';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

use Symfony\Component\Security\Core\Exception\AuthenticationException;

/**
* @final
*/
class TwoFactorProviderNotFoundException extends AuthenticationException
{
public const MESSAGE_KEY = 'Two-factor provider not found.';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;

/**
* @final
*/
class AuthenticationProviderDecorator implements AuthenticationProviderInterface
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Exception\AuthenticationException;

/**
* @final
*/
class TwoFactorAuthenticationProvider implements AuthenticationProviderInterface
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
use Symfony\Component\Security\Http\Logout\LogoutHandlerInterface;
use Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface;

/**
* @final
*/
class RememberMeServicesDecorator implements RememberMeServicesInterface, LogoutHandlerInterface
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;

/**
* @final
*/
class TwoFactorTokenFactory implements TwoFactorTokenFactoryInterface
{
public function create(TokenInterface $authenticatedToken, string $providerKey, array $twoFactorProviders): TwoFactorTokenInterface
Expand Down
3 changes: 3 additions & 0 deletions src/bundle/Security/Authorization/TwoFactorAccessDecider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
use Symfony\Component\Security\Http\HttpUtils;
use Symfony\Component\Security\Http\Logout\LogoutUrlGenerator;

/**
* @final
*/
class TwoFactorAccessDecider
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
use Symfony\Component\Security\Core\Authorization\Voter\AuthenticatedVoter;
use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;

/**
* @final
*/
class TwoFactorInProgressVoter implements VoterInterface
{
public const IS_AUTHENTICATED_2FA_IN_PROGRESS = 'IS_AUTHENTICATED_2FA_IN_PROGRESS';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

use Symfony\Component\Security\Http\Authenticator\Passport\Badge\BadgeInterface;

/**
* @final
*/
class RememberMeBadge implements BadgeInterface
{
public function isResolved(): bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

use Symfony\Component\Security\Http\Authenticator\Passport\Credentials\CredentialsInterface;

/**
* @final
*/
class TwoFactorCodeCredentials implements CredentialsInterface
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
use Symfony\Component\Security\Http\Authenticator\Passport\PassportInterface;
use Symfony\Component\Security\Http\Authenticator\Passport\PassportTrait;

/**
* @final
*/
class TwoFactorPassport implements PassportInterface
{
use PassportTrait;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
use Symfony\Component\Security\Http\Authenticator\Passport\PassportInterface;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;

/**
* @final
*/
class TwoFactorAuthenticator implements AuthenticatorInterface, InteractiveAuthenticatorInterface
{
public const FLAG_2FA_COMPLETE = '2fa_complete';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Http\Event\CheckPassportEvent;

/**
* @internal
*/
abstract class AbstractCheckCodeListener implements EventSubscriberInterface
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
use Scheb\TwoFactorBundle\Security\TwoFactor\Provider\TwoFactorProviderRegistry;
use Symfony\Component\Security\Http\Event\CheckPassportEvent;

/**
* @final
*/
class CheckTwoFactorCodeListener extends AbstractCheckCodeListener
{
public const LISTENER_PRIORITY = 0;
Expand Down
3 changes: 3 additions & 0 deletions src/bundle/Security/Http/EventListener/RememberMeListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Http\Event\LoginSuccessEvent;

/**
* @final
*/
class RememberMeListener implements EventSubscriberInterface
{
public function onSuccessfulLogin(LoginSuccessEvent $event): void
Expand Down
3 changes: 3 additions & 0 deletions src/bundle/Security/Http/Firewall/ExceptionListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;

/**
* @final
*/
class ExceptionListener implements EventSubscriberInterface
{
// Just before the firewall's Symfony\Component\Security\Http\Firewall\ExceptionListener
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@
use Symfony\Component\Security\Http\Firewall\FirewallListenerInterface as BaseFirewallListenerInterface;

if (interface_exists(BaseFirewallListenerInterface::class)) {
// Compatibility for Symfony >= 5.2
/**
* @internal Compatibility for Symfony >= 5.2
*/
interface FirewallListenerInterface extends BaseFirewallListenerInterface
{
}
} else {
// Compatibility for Symfony <= 5.1
/**
* @internal Compatibility for Symfony <= 5.1
*/
interface FirewallListenerInterface
{
}
Expand Down
2 changes: 2 additions & 0 deletions src/bundle/Security/Http/Firewall/TwoFactorAccessListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

/**
* Handles access control in the "2fa in progress" phase.
*
* @final
*/
class TwoFactorAccessListener extends AbstractListener implements FirewallListenerInterface
{
Expand Down
3 changes: 3 additions & 0 deletions src/bundle/Security/Http/Firewall/TwoFactorListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface;
use Symfony\Component\Security\Http\Firewall\AbstractListener;

/**
* @final
*/
class TwoFactorListener extends AbstractListener
{
/**
Expand Down
Loading

0 comments on commit cc7028a

Please sign in to comment.