aws_auth 1.0.0+1 copy "aws_auth: ^1.0.0+1" to clipboard
aws_auth: ^1.0.0+1 copied to clipboard

outdated

Low-level library for signing AWS API requests.

aws_auth #

CI codecov Pub

A low-level library for signing AWS API requests in Dart.

Using #

Create a AWSCredentials object with your AWS secrets:

final credentials = AWSCredentials(
  'AWS_ACCESS_KEY_ID',
  'AWS_SECRET_ACCESS_KEY',
  sessionToken: 'AWS_SESSION_TOKEN',  // this is optional
);

Initialize AWS4Signer for the given region and service:

final signer = AWS4Signer(credentials, 'eu-central-1', 'sts');

Create AWSRequest object and pass it to sign or presign method of the signer (see examples below). Signer will modify request in place and add required headers or query parameters (in case of presigning) with authentication information.

POST request with an authorization header #

final req = AWSRequest.formData(
  'https://sts.eu-central-1.amazonaws.com/',
  body: {
    'Action': 'GetCallerIdentity',
    'Version': '2011-06-15',
  },
);
signer.sign(req);

print(req.headers['Authorization'])
print(req.headers['X-Amz-Date'])

GET request with authentication information in the query string (presigned url) #

final req = AWSRequest(
  'https://sts.eu-central-1.amazonaws.com/',
  queryParameters: {
    'Action': 'GetCallerIdentity',
    'Version': '2011-06-15',
  },
);
signer.presign(req);

print(req.url);
8
likes
30
pub points
47%
popularity

Publisher

verified publisherbacic.dev

Low-level library for signing AWS API requests.

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

collection, convert, crypto, intl

More

Packages that depend on aws_auth