Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.
/ logintc-php Public archive

The LoginTC PHP client is a complete LoginTC REST API client to manage LoginTC organizations, users, domains, tokens and to create login sessions.

License

Notifications You must be signed in to change notification settings

logintc/logintc-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

The LoginTC PHP client is a complete LoginTC REST API client to manage LoginTC organizations, users, domains, tokens and to create login sessions.

This package allows a developer to quickly add multi-factor authentication to their web or portal login forms.

Installation

Get the code:

git clone https://github.com/logintc/logintc-php.git

Example

<?php

require_once('LoginTC.php');

try {

    /*
     * instantiate the LoginTC client
     */

    $api_key = 'YOUR_API_KEY';

    $logintc = new LoginTC($api_key);

    /*
     * create a session
     */

    $domain_id = 'YOUR_DOMAIN_ID';
    $username = 'usertest';
    
    $domainAttribute = new DomainAttribute("Disclaimer", "Unauthorized access or use of this site (and any connected systems data) is prohibited");
    $attributes = array($domainAttribute);

    $session = $logintc->createSessionWithUsername($domain_id, $username, $attributes);

    /*
     * poll the state of the session
     */

    $t = time();
    $timeout = 45;
    $response = null;
    while ((time() - $t) < $timeout) {

        $polled_session = $logintc->getSession($domain_id, $session->getId());

        if ($polled_session->getState() != 'pending') {
            break;
        }

        sleep(1); // wait 1s
    }

    /*
     * check final state of the session
     */

    if ($polled_session->getState() === 'denied') {
        // denied or timeout
    }

    if ($polled_session->getState() === 'approved') {
        // user authenticated!
        // log user in here
    }

} catch (LoginTCException $exception) {
    die($exception->getMessage());
}


?>

Documentation

See https://www.logintc.com/docs

Help

Email: [email protected]

https://www.logintc.com

About

The LoginTC PHP client is a complete LoginTC REST API client to manage LoginTC organizations, users, domains, tokens and to create login sessions.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages