TotpProvider implements MfaProviderInterface
MFA provider for time-based one-time password authentication
should only be used by the TYPO3 Core
Table of Contents
Interfaces
- MfaProviderInterface
- To be implemented by all MFA providers.
Properties
Methods
- __construct() : mixed
- activate() : bool
- Activate the provider by checking the necessary parameters, verifying the TOTP and storing the provider properties.
- canProcess() : bool
- Check if a TOTP is given in the current request
- deactivate() : bool
- Handle the deactivate action. For security reasons, the provider entry is completely deleted and setting up this provider again, will therefore create a brand new entry.
- handleRequest() : ResponseInterface
- Initialize view and forward to the appropriate implementation based on the view type to be returned.
- isActive() : bool
- Evaluate if the provider is activated by checking the active state and the secret from the provider properties.
- isLocked() : bool
- Evaluate if the provider is temporarily locked by checking the current attempts state from the provider properties.
- unlock() : bool
- Handle the unlock action by resetting the attempts provider property
- update() : bool
- Handle the save action by updating the provider properties
- verify() : bool
- Verify the given TOTP and update the provider properties in case the TOTP is valid.
- getDateTime() : string
- Return the timestamp as local time (date string) by applying the globally configured format
- getSvgQrCode() : string
- Internal helper method for generating a svg QR-code for TOTP applications
- getTotp() : string
- Internal helper method for fetching the TOTP from the request
- prepareAuthView() : void
- Set the template for the auth view where the user has to provide the TOTP
- prepareEditView() : void
- Set the template and assign necessary variables for the edit view
- prepareSetupView() : void
- Generate a new shared secret, generate the otpauth URL and create a qr-code for improved usability. Set template and assign necessary variables for the setup view.
Properties
$context
protected
Context
$context
Methods
__construct()
public
__construct(Context $context) : mixed
Parameters
- $context : Context
activate()
Activate the provider by checking the necessary parameters, verifying the TOTP and storing the provider properties.
public
activate(ServerRequestInterface $request, MfaProviderPropertyManager $propertyManager) : bool
Parameters
- $request : ServerRequestInterface
- $propertyManager : MfaProviderPropertyManager
Return values
boolcanProcess()
Check if a TOTP is given in the current request
public
canProcess(ServerRequestInterface $request) : bool
Parameters
- $request : ServerRequestInterface
Return values
booldeactivate()
Handle the deactivate action. For security reasons, the provider entry is completely deleted and setting up this provider again, will therefore create a brand new entry.
public
deactivate(ServerRequestInterface $request, MfaProviderPropertyManager $propertyManager) : bool
Parameters
- $request : ServerRequestInterface
- $propertyManager : MfaProviderPropertyManager
Return values
boolhandleRequest()
Initialize view and forward to the appropriate implementation based on the view type to be returned.
public
handleRequest(ServerRequestInterface $request, MfaProviderPropertyManager $propertyManager, string $type) : ResponseInterface
Parameters
- $request : ServerRequestInterface
- $propertyManager : MfaProviderPropertyManager
- $type : string
Return values
ResponseInterfaceisActive()
Evaluate if the provider is activated by checking the active state and the secret from the provider properties.
public
isActive(MfaProviderPropertyManager $propertyManager) : bool
Parameters
- $propertyManager : MfaProviderPropertyManager
Return values
boolisLocked()
Evaluate if the provider is temporarily locked by checking the current attempts state from the provider properties.
public
isLocked(MfaProviderPropertyManager $propertyManager) : bool
Parameters
- $propertyManager : MfaProviderPropertyManager
Return values
boolunlock()
Handle the unlock action by resetting the attempts provider property
public
unlock(ServerRequestInterface $request, MfaProviderPropertyManager $propertyManager) : bool
Parameters
- $request : ServerRequestInterface
- $propertyManager : MfaProviderPropertyManager
Return values
boolupdate()
Handle the save action by updating the provider properties
public
update(ServerRequestInterface $request, MfaProviderPropertyManager $propertyManager) : bool
Parameters
- $request : ServerRequestInterface
- $propertyManager : MfaProviderPropertyManager
Return values
boolverify()
Verify the given TOTP and update the provider properties in case the TOTP is valid.
public
verify(ServerRequestInterface $request, MfaProviderPropertyManager $propertyManager) : bool
Parameters
- $request : ServerRequestInterface
- $propertyManager : MfaProviderPropertyManager
Return values
boolgetDateTime()
Return the timestamp as local time (date string) by applying the globally configured format
protected
getDateTime(int $timestamp) : string
Parameters
- $timestamp : int
Return values
stringgetSvgQrCode()
Internal helper method for generating a svg QR-code for TOTP applications
protected
getSvgQrCode(string $content) : string
Parameters
- $content : string
Return values
stringgetTotp()
Internal helper method for fetching the TOTP from the request
protected
getTotp(ServerRequestInterface $request) : string
Parameters
- $request : ServerRequestInterface
Return values
stringprepareAuthView()
Set the template for the auth view where the user has to provide the TOTP
protected
prepareAuthView(StandaloneView $view, MfaProviderPropertyManager $propertyManager) : void
Parameters
- $view : StandaloneView
- $propertyManager : MfaProviderPropertyManager
prepareEditView()
Set the template and assign necessary variables for the edit view
protected
prepareEditView(StandaloneView $view, MfaProviderPropertyManager $propertyManager) : void
Parameters
- $view : StandaloneView
- $propertyManager : MfaProviderPropertyManager
prepareSetupView()
Generate a new shared secret, generate the otpauth URL and create a qr-code for improved usability. Set template and assign necessary variables for the setup view.
protected
prepareSetupView(StandaloneView $view, MfaProviderPropertyManager $propertyManager) : void
Parameters
- $view : StandaloneView
- $propertyManager : MfaProviderPropertyManager