Exemplo n.º 1
0
function generate_signature($service, $operation, $timestamp, $secret_access_key)
{
    $string_to_encode = $service . $operation . $timestamp;
    $hmac = hmac_sha1($secret_access_key, $string_to_encode);
    $signature = base64_encode($hmac);
    return $signature;
}
Exemplo n.º 2
0
    header("HTTP/1.1 401 Unauthorized");
}
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
?>
<!DOCTYPE html>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Single Sign-On</title>
</head>
<body>

<?php 
$time = round(microtime(true) * 1000);
$url = 'https://myzimbra.com/service/preauth?account=' . $_SERVER['AUTHENTICATE_SAMACCOUNTNAME'] . '@myzimbra.com&expires=0&timestamp=' . $time . '&preauth=' . hmac_sha1('YOUR PRE-AUTH KEY HERE', $_SERVER['AUTHENTICATE_SAMACCOUNTNAME'] . '@myzimbra.com|name|0|' . $time);
function hmac_sha1($key, $data)
{
    // Adjust key to exactly 64 bytes
    if (strlen($key) > 64) {
        $key = str_pad(sha1($key, true), 64, chr(0));
    }
    if (strlen($key) < 64) {
        $key = str_pad($key, 64, chr(0));
    }
    // Outter and Inner pad
    $opad = str_repeat(chr(0x5c), 64);
    $ipad = str_repeat(chr(0x36), 64);
    // Xor key with opad & ipad
    for ($i = 0; $i < strlen($key); $i++) {
        $opad[$i] = $opad[$i] ^ $key[$i];