Deployment Guide

Table Of Contents
const AWS4_ERROR_MISSING_QUERY_PARAMS=16;
const AWS4_ERROR_MISSING_CRED_PARAMS=17;
const AWS4_ERROR_STALE_REQUEST=2001;
const AWS4_ERROR_UNKNOWN_IDENTITY=2002;
const AWS4_EXTREME_REQUEST="aws4_request";
const AWS4_MAX_URL_SIZE= 512;
const AWS4_HTTP_REQ = "http://";
const AWS4_HTTPS_REQ= "https://";
const AWS4_MANDATORY_CRED_PARAMS = 4;
/**
* Method to verify the AWS signature based on given full URL address.
*
* @param string $pUrl
* @param array $awsKeyPairs identity, shared secret key pairs
* @return AWS error code
*/
public static function verifyAwsUrlSignature($pUrl,
$awsKeyPairs) {
// Perform basic validation
if($pUrl==NULL) {
return self::AWS4_ERROR_NULL_INPUT;
}
if (2*self::AWS4_MAX_URL_SIZE < strlen($pUrl)) {
return self::AWS4_ERROR_INPUT_URL_TOO_BIG;
}
if(stripos($pUrl, self::AWS4_HTTP_REQ)!=0 || stripos($pUrl, self::AWS4_HTTPS_REQ)!
=0) {
return self::AWS4_ERROR_INVALID_PROTOCOL;
}
$urlParams = parse_url($pUrl);
if (!isset($urlParams['query'])) {
return self::AWS4_ERROR_MISSING_QUERY;
}
$queryParams = explode("&", $urlParams['query']);
foreach($queryParams AS $el) {
$arr = explode("=", $el);
$q[$arr[0]] = $arr[1];
}
$valResult = self::validateQueryParms($q);
if (self::AWS4_ERROR_NONE != $valResult) {
return $valResult;
}
// Done with the basic validations.
$date = $q['X-Amz-Date'];
$sign = $q['X-Amz-Signature'];
$credentVal = rawurldecode($q['X-Amz-Credential']);
ksort($q);
// Remove the signature from the list of parameters over
// which the signature will be recomputed.
unset($q['X-Amz-Signature']);
$credentAttrs = explode("/", $credentVal);
$pKey = $credentAttrs[0];
if (self::AWS4_MAX_URL_SIZE < strlen($pKey)) {
return self::AWS4_ERROR_INPUT_KEY_TOO_BIG;
}
if(self::AWS4_MANDATORY_CRED_PARAMS > count($credentAttrs)) {
return self::AWS4_ERROR_MISSING_CRED_PARAMS;
}
if (!isset($awsKeyPairs[$pKey])) {
return self::AWS4_ERROR_UNKNOWN_IDENTITY;
}
$scope = $credentAttrs[1]."/".$credentAttrs[2]."/"
.$credentAttrs[3]."/".$credentAttrs[4];
$port = $urlParams['port'];
crypt_aws_s4.php
PHP External Captive Portal, Controller’s Firewall
Friendly API
208 Extreme Campus Controller Deployment Guide for version 5.46.03