AuthAws Chilkat2 Perl Reference Documentation
Chilkat2::AuthAws
Current Version: 11.7.0
Markdown version of this page for AI tools (v 11.7.0) · all AI docs
Chilkat.AuthAws
Provide AWS signing settings to
Sign requests using AWS Signature Version 4, including service, region,
credentials, headers, and request payload details.
Use access keys and secret keys directly, or use secret specifiers when
credentials should be resolved from a secure credential source.
Configure the AWS region and service name so signatures are generated
for the correct AWS endpoint.
Include session tokens when signing requests with temporary AWS
credentials from STS, IAM roles, or similar credential flows.
Generate temporary Signature V4 pre-signed URLs when a client needs
limited-time access without sending AWS credentials.
For an extended overview, see
AuthAws Class Overview.
Configure AWS request signing for REST calls and temporary pre-signed URLs.
Chilkat.AuthAws holds the AWS authentication settings used by
Chilkat.Rest when sending signed AWS requests. It supports AWS
Signature Version 4 by default, can optionally use the older Signature
Version 2 where applicable, accepts direct credential values or secure secret
specifiers, and can generate temporary Signature V4 pre-signed URLs for AWS
services.
REST authentication object
Chilkat.Rest so outgoing
requests are authenticated according to AWS requirements.
Signature Version 4
Credentials and secrets
Region and service targeting
Temporary credentials
Pre-signed URLs
AuthAws object with the AWS access key,
secret key or secret specifier, region, service name, and optional session
token, then pass it to Chilkat.Rest before sending the request.
Use AuthAws for AWS request signing; use service-specific
Chilkat classes or Chilkat.Http/Chilkat.Rest for
constructing and sending the actual API request.
Object Creation
use Chilkat2;
my $authAws = Chilkat2::AuthAws->new;
# or set properties (and RaiseError) at creation:
# my $authAws = Chilkat2::AuthAws->new(VerboseLogging => 1, RaiseError => 1);Creates the object. The optional pairs set writable properties (and RaiseError) in order, as if set one by one; an unknown or read-only name croaks. use Chilkat2; loads every class; the Chilkat2/AuthAws.pm file holds only this class's documentation (perldoc Chilkat2::AuthAws).
Perl frees the object when its last reference goes (undef $authAws, or the variable going out of scope); there is nothing to close. Objects returned by methods are independent and freed the same way. The class may be subclassed (use parent -norequire, 'Chilkat2::AuthAws';): an object is a blessed hash reference whose hash is free for the subclass's own fields.
When false (the default), a method that fails returns false (or undef), and the reason is in LastErrorText. When true, it dies with a Chilkat2::Error instead, as DBI does with its RaiseError. Objects returned by a method inherit the value of the object that returned them.
Errors
A Chilkat2::Error stringifies to the failed call's full LastErrorText, and has the methods text, class ('Chilkat2::AuthAws'), method (the method name) and object. Methods that look something up and find nothing return undef without dying (each such method says so), methods that answer a question (HasMember, IsUnlocked, ...) return a plain boolean, and property reads and writes never fail for Chilkat reasons.
Misuse always croaks, with your file and line, whatever RaiseError is: a wrong number of arguments, a reference or undef where a string or number is expected, an object of the wrong class, an out-of-range integer, a string containing a NUL character, a wide character in a byte string, or a write to a read-only property.
Strings are Perl character strings in both directions (length, regexes and :encoding layers see characters); binary data (BinData) is a byte string. Unlocking: call Chilkat2::Global->new->UnlockBundle('...') once at startup.
Properties
AccessKey
my $strVal = $authAws->AccessKey;
$authAws->AccessKey($strVal);
The AWS access key.
topCanonicalizedResourceV2
my $strVal = $authAws->CanonicalizedResourceV2;
$authAws->CanonicalizedResourceV2($strVal);
If AWS Signature Version V2 is used, then this property must be set. The rules for setting the canonicalized resource for the V2 signature method is described here: Constructing the CanonicalizedResource Element.
DebugLogFilePath
my $strVal = $authAws->DebugLogFilePath;
$authAws->DebugLogFilePath($strVal);
If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. This logging helps identify the context and history of Chilkat calls leading up to any crash or hang, aiding in debugging.
Enabling the VerboseLogging property provides more detailed information. This property is mainly used for debugging rare instances where a Chilkat method call causes a hang or crash, which should generally not happen.
Possible causes of hangs include:
- A timeout property set to 0, indicating an infinite timeout.
- A hang occurring within an event callback in the application code.
- An internal bug in the Chilkat code causing the hang.
EnableSecrets
my $boolVal = $authAws->EnableSecrets;
$authAws->EnableSecrets($boolVal);
If 1 a secret specifier of the format "!!part1|part2|.." can be provided instead of the actual value for the AccessKey and SecretKey properties.
The default value is 0.
LastErrorHtml
my $strVal = $authAws->LastErrorHtml;
Provides HTML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.
topLastErrorText
my $strVal = $authAws->LastErrorText;
Provides plain text information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.
LastErrorXml
my $strVal = $authAws->LastErrorXml;
Provides XML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.
topLastMethodSuccess
my $boolVal = $authAws->LastMethodSuccess;
$authAws->LastMethodSuccess($boolVal);
Indicates the success or failure of the most recent method call: 1 means success, 0 means failure. This property remains unchanged by property setters or getters. This method is present to address challenges in checking for null or Nothing returns in certain programming languages. Note: This property does not apply to methods that return integer values or to boolean-returning methods where the boolean does not indicate success or failure.
PrecomputedMd5
my $strVal = $authAws->PrecomputedMd5;
$authAws->PrecomputedMd5($strVal);
This property can optionally be set for AWS requests that have a non-empty request body. This should be the base64 encoding of the 16 bytes of the MD5 hash. The most common need for this is if doing an S3 upload from a stream. (If the pre-computed MD5 is not provided, then Chilkat is forced to stream the entire file into memory so that it can calculate the MD5 for authentication.)
Note: AWS Signature Version 2 uses the MD5, whereas Signature Version 4 uses SHA256.
topPrecomputedSha256
my $strVal = $authAws->PrecomputedSha256;
$authAws->PrecomputedSha256($strVal);
This property can optionally be set for AWS requests that have a non-empty request body. This should be the lowercase hex encoding of the 32-bytes of the SHA256 hash. The most common need for this is if doing an S3 upload from a stream. (If the pre-computed SHA-256 is not provided, then Chilkat is forced to stream the entire file into memory so that it can calculate the SHA-256 for authentication.)
Note: AWS Signature Version 4 uses the SHA256 hash. (AWS Signature Version 2 uses MD5)
Region
my $strVal = $authAws->Region;
$authAws->Region($strVal);
The AWS region, such as us-east-1, us-west-2, eu-west-1, eu-central-1, etc. The default is us-east-1. It is only used when the SignatureVersion property is set to 4. This property is unused when the SignatureVersion property is set to 2.
SecretKey
my $strVal = $authAws->SecretKey;
$authAws->SecretKey($strVal);
The AWS secret key.
topServiceName
my $strVal = $authAws->ServiceName;
$authAws->ServiceName($strVal);
The AWS service namespace, such as s3, ses, etc. See http://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html#genref-aws-service-namespaces
This property is unused when the SignatureVersion property is set to 2.
topSignatureVersion
my $intVal = $authAws->SignatureVersion;
$authAws->SignatureVersion($intVal);
The AWS Signature Version to be used in authentication. The default value is 4. This can optionally be set to the value 2 to use the older V2 signature version.
topVerboseLogging
my $boolVal = $authAws->VerboseLogging;
$authAws->VerboseLogging($boolVal);
If set to 1, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. The default value is 0. Verbose logging should only be used for debugging. The potentially large quantity of logged information may adversely affect peformance.
Version
my $strVal = $authAws->Version;
Methods
GenPresignedUrl
# $useHttps is a boolean
# $domain is a string
# $path is a string
# $numSecondsValid is an integer
# $awsService is a string
# $str is a string or undef
my $str = $authAws->GenPresignedUrl($httpVerb, $useHttps, $domain, $path, $numSecondsValid, $awsService);
Generates a temporary pre-signed URL for an Amazon AWS service using AWS Signature V4. Requires that the SecretKey, AccessKey, and Region properties be set to valid values prior to calling this method.
The URL that is generated has this format:
https://<domain>/<path> ?X-Amz-Algorithm=AWS4-HMAC-SHA256 &X-Amz-Credential=<AccessKey>/<currentDate>/<Region>/<awsService>/aws4_request &X-Amz-Date=<currentDateTime> &X-Amz-Expires=<numSecondsValid> &X-Amz-SignedHeaders=host &X-Amz-Signature=<signature-value>
The $httpVerb is the HTTP verb such as GET, PUT, POST, DELETE, etc. The $awsService is a string naming the AWS service, such as s3, execute-api, etc. If $useHttps is 1, then the returned URL begins with https://, otherwise it begins with http://.
Note: It is generally not feasible to use pre-signed URLs for POST operations for any AWS service except for S3. See AWS Pre-Signed URLs for POST Operations (non-S3)
Returns undef on failure; LastErrorText says why. With RaiseError on, a failure dies with a Chilkat2::Error instead (it stringifies to the LastErrorText); the object remains usable either way.