File Information
Library: OSP/Auth/TwoFactor
Package: TwoFactor
Header: Poco/OSP/Auth/TwoFactor/TwoFactorService.h
Description
This service helps to implement two-factor authentication using Time-based One-Time Passwords (TOTPs) specified in RFC 6238 and supported by Google Authenticator or Authy.
Inheritance
Direct Base Classes: Poco::OSP::Service
All Base Classes: Poco::OSP::Service, Poco::RefCountedObject
Known Derived Classes: TwoFactorServiceImpl
Member Summary
Member Functions: disable2FA, enable2FA, generateAuthenticatorURI, is2FAEnabled, isA, secret, type, validateTOTP
Inherited Functions: duplicate, isA, referenceCount, release, type
Types Aliases
Ptr
using Ptr = Poco::AutoPtr < TwoFactorService >;
Enumerations
ValidationResult
VALIDATION_FAILED_CODE_INCORRECT
VALIDATION_FAILED_CODE_ALREADY_USED
Member Functions
disable2FA
virtual void disable2FA(
const std::string & username
) = 0;
Disables two-factor authentication for the given username and deletes the stored secret for the user.
enable2FA
virtual void enable2FA(
const std::string & username
) = 0;
Enables two-factor authentication for the given username and generates a secret for the user.
generateAuthenticatorURI
virtual std::string generateAuthenticatorURI(
const std::string & username
) const = 0;
Generates a TOTP URI with the secret suitable for encoding as QR code for importing into Google Authenticator and similar apps.
is2FAEnabled
virtual bool is2FAEnabled(
const std::string & username
) const = 0;
Returns true if two-factor authentication has been enabled for the given username.
isA
bool isA(
const std::type_info & otherType
) const;
See also: Poco::OSP::Service::isA()
secret
virtual std::string secret(
const std::string & username
) const = 0;
Returns the base32-encoded secret for the given username.
type
const std::type_info & type() const;
See also: Poco::OSP::Service::type()
validateTOTP
virtual ValidationResult validateTOTP(
const std::string & username,
const std::string & totp
) = 0;
Validates the given time-based one-time password.
Variables
SERVICE_NAME
static const std::string SERVICE_NAME;