public function __construct($config)
 {
     parent::__construct($config);
 }
Exemplo n.º 2
0
#
if (isset($_GET['code'])) {
    # Once the user has logged-in with their credentials, they get re-directed to this URL
    # with a 'code' parameter. This is exchanged for an access token which can be used in any
    # future calls to the AT&T APIs
    if (isset($_GET['returnUrl'])) {
        $return_url = urldecode($_GET['returnUrl']);
    } else {
        http_response_code(500);
        // Set response code to 500
        echo "user authentication completed but I don't have a returnUrl to go back to";
        exit;
    }
    $code = trim($_GET['code']);
    try {
        $html5_provider = new Html5_ServiceProvider_Base_Att($config);
        $token = $html5_provider->getToken($code);
        # Store the auth token in the session for use in future API calls
        if (isset($_GET['scopes'])) {
            $scopes = explode(",", $_GET['scopes']);
            foreach ($scopes as $key => $value) {
                $_SESSION['consent_tokens'][$value] = $token->getAccessToken();
                $_SESSION['consent_expires_at'][$value] = $token->getTokenExpiry();
                $_SESSION['consent_refresh_tokens'][$value] = $token->getRefreshToken();
            }
        }
    } catch (Exception $e) {
        if (strpos($return_url, '?') === FALSE) {
            $return_url = $return_url . "?";
        } else {
            $return_url = $return_url . "&";
Exemplo n.º 3
0
<?php

if (!file_exists("config.php")) {
    header('X-PHP-Response-Code: 400', true, 400);
    header("Content-Type:application/json");
    echo "{\"error\":\"config.php does not exist.\"}";
    exit;
} else {
    require_once "config.php";
}
if (!file_exists("service_provider/Html5_ServiceProvider_Base_Att.php")) {
    header('X-PHP-Response-Code: 400', true, 400);
    header("Content-Type:application/json");
    echo "{\"error\":\"service_provider/Html5_ServiceProvider_Base_Att.php does not exist.\"}";
    exit;
} else {
    require_once "service_provider/Html5_ServiceProvider_Base_Att.php";
}
header("Content-Type:application/json");
if (isset($_GET['returnUrl']) && isset($_GET['scope'])) {
    $scope = $_GET['scope'];
    $return_url = $_GET['returnUrl'];
    $html5_provider = new Html5_ServiceProvider_Base_Att($config);
    $custom_param = isset($_GET['custom_param']) ? $_GET['custom_param'] : null;
    $user_auth_url = $html5_provider->oauthUrl($scope, $return_url, $custom_param);
    echo "{\"url\":\"" . $user_auth_url . "\"}";
} else {
    http_response_code(400);
    // Set response code to 400 - Bad Request in case of all exceptions
    echo "{\"error\": \"scope and returnUrl querystring parameters must be specified\"}";
}
Exemplo n.º 4
0
if (isset($_GET['scope'])) {
    $tokens = isset($_SESSION['consent_tokens']) ? $_SESSION['consent_tokens'] : '';
    $scopes = explode(",", $_GET['scope']);
    if (is_array($tokens)) {
        foreach ($scopes as $s) {
            $temp_bool = false;
            foreach ($tokens as $key => $value) {
                if ($key == $s) {
                    $expires_at = $_SESSION['consent_expires_at'][$key];
                    $time_now = getdate()[0];
                    $expires_in = $expires_at - $time_now - $reduce_token_expiry_by;
                    if ($expires_in > 0) {
                        $bool = "true";
                        $temp_bool = true;
                    } else {
                        $html5_provider = new Html5_ServiceProvider_Base_Att($config);
                        // Try to get the token, this will try the refresh logic
                        $token = $html5_provider->getSessionConsentToken($key);
                        if ($token != null) {
                            $bool = "true";
                            $temp_bool = true;
                        }
                    }
                }
            }
            if (!$temp_bool) {
                $bool = "false";
                break;
            }
        }
    }
Exemplo n.º 5
0
if (!file_exists("config.php")) {
    header('X-PHP-Response-Code: 400', true, 400);
    header("Content-Type:application/json");
    echo "{\"error\":\"config.php does not exist.\"}";
    exit;
} else {
    require_once "config.php";
}
try {
    if (!file_exists("service_provider/Html5_ServiceProvider_Base_Att.php")) {
        throw new Exception('service_provider/Html5_ServiceProvider_Base_Att.php does not exist');
    } else {
        require_once "service_provider/Html5_ServiceProvider_Base_Att.php";
    }
    $html5_serviceprovider_base = new Html5_ServiceProvider_Base_Att($config);
    if (isset($_GET['scope'])) {
        $scope = $_GET['scope'];
        if (DEBUG) {
            Debug::init();
            $a = $_SESSION['consent_refresh_tokens'][$scope];
            Debug::write("Revoke Old Refresh token: {$a}.\n");
            Debug::end();
        }
        if (isset($_SESSION['consent_tokens'][$scope])) {
            $html5_serviceprovider_base->revokeConsentToken($scope);
            //unset($_SESSION['consent_tokens'][$scope]);
        }
    } else {
        if (DEBUG) {
            Debug::init();
Exemplo n.º 6
0
if (!file_exists("config.php")) {
    header('X-PHP-Response-Code: 400', true, 400);
    header("Content-Type:application/json");
    echo "{\"error\":\"config.php does not exist.\"}";
    exit;
} else {
    require_once "config.php";
}
try {
    if (!file_exists("service_provider/Html5_ServiceProvider_Base_Att.php")) {
        throw new Exception('service_provider/Html5_ServiceProvider_Base_Att.php does not exist');
    } else {
        require_once "service_provider/Html5_ServiceProvider_Base_Att.php";
    }
    $html5_serviceprovider_base = new Html5_ServiceProvider_Base_Att($config);
    $revoke = '';
    if (isset($_GET['revoke'])) {
        $revoke = $_GET['revoke'];
    } else {
        if (isset($_POST['revoke'])) {
            $revoke = $_POST['revoke'];
        }
    }
    if ($revoke == 'client') {
        $html5_serviceprovider_base->revokeClientToken();
    } else {
        if ($revoke == 'consent') {
            $html5_serviceprovider_base->revokeConsentToken('MIM');
            $html5_serviceprovider_base->revokeConsentToken('IMMN');
        } else {