Poco::OSP::Auth::TwoFactor

class TwoFactorService

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_SUCCEEDED

VALIDATION_FAILED_CODE_INCORRECT

VALIDATION_FAILED_CODE_ALREADY_USED

Member Functions

disable2FA virtual

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

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

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

virtual bool is2FAEnabled(
    const std::string & username
) const = 0;

Returns true if two-factor authentication has been enabled for the given username.

isA virtual

bool isA(
    const std::type_info & otherType
) const;

secret virtual

virtual std::string secret(
    const std::string & username
) const = 0;

Returns the base32-encoded secret for the given username.

type virtual

const std::type_info & type() const;

validateTOTP virtual

virtual ValidationResult validateTOTP(
    const std::string & username,
    const std::string & totp
) = 0;

Validates the given time-based one-time password.

Variables

SERVICE_NAME static

static const std::string SERVICE_NAME;

Securely control IoT edge devices from anywhere   Connect a Device