Git Product home page Git Product logo

aws_auth's Introduction

aws_auth

CI codecov Pub

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

Using

Create AWSCredentialsProvider object. In order to set credentials programatically, you can use AWSStaticCredentialsProvider class:

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

You can implement your own provider e.g. if you need to dynamically retrieve the credentials and refresh them periodically.

Initialize AWS4Signer for the given region and service:

final signer = AWS4Signer(
  credentialsProvider, 
  region: 'eu-central-1', 
  serviceName:'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);

aws_auth's People

Contributors

jakub-bacic avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.