Skip to main content

AWS IAM Authorizer.

Project description

Requests IAMAuth

pypi python pytest coverage maintainability

Use AWS SigV4 authorization with requests.

Accessing an API secured with IAM authorization in AWS API Gateway can be tricky.

This tool uses the built-in authorization strategy in requests to help you access your secured endpoints.

Installation

pip install requests-iamauth

Usage

Signing Version 4

AWS sigv4 is the current standard for signing requests bound for AWS services.

Use requests-iamauth to as an authorizer for the requests Python library:

import requests
from iamauth import Sigv4Auth

sigv4 = Sigv4Auth(
  service_name="execute-api",  # default
)

session = requests.Session()
session.auth = sigv4
session.get('https://abcdef0123.execute-api.us-east-2.amazonaws.com/my/api')

Override the default boto3 session by passing a custom one into the constructor for Sigv4Auth:

import boto3

sigv4 = Sigv4Auth(
  boto3_session=boto3.Session(),
)

Signing Version 4a

AWS sigv4a is an extension to the sigv4 signing process that enables signing requests bound for more than one region.

Note — at the time of this writing, the only API Gateway API type that appears to support sigv4 are REST APIs.

Use requests-iamauth to as an authorizer for the requests Python library:

import requests
from iamauth import Sigv4aAuth

sigv4a = Sigv4aAuth(
  service="execute-api",  # default
  region="*",             # default
)

session = requests.Session()
session.auth = sigv4a
session.get('https://abcdef0123.execute-api.us-east-2.amazonaws.com/my/api')

Override the default AWS credentials provider by passing a custom one into the constructor for Sigv4aAuth:

from botocore.compat import awscrt

sigv4a = Sigv4aAuth(
  credentials_provider=awscrt.auth.AwsCredentialsProvider.new_default_chain(),
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iamauth-0.7.0.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

iamauth-0.7.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file iamauth-0.7.0.tar.gz.

File metadata

  • Download URL: iamauth-0.7.0.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.28.1

File hashes

Hashes for iamauth-0.7.0.tar.gz
Algorithm Hash digest
SHA256 5f3b5aa567011ca240ff8d849b233f0fb0651e3c8691dc9eb461f6be39355219
MD5 c6514d141f7ebe6e0867d8b334c4c110
BLAKE2b-256 f76f878f8f567ae4dbb84d4fb544d671d83439a97573499b8ac0222492183ed2

See more details on using hashes here.

File details

Details for the file iamauth-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: iamauth-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.28.1

File hashes

Hashes for iamauth-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ece1b2356e369fd6a029edfa52981392090ae455126cc7a2fde1a724600d8d78
MD5 fdce892606ad69c2ff7a7fdaac0357d4
BLAKE2b-256 15af50586736888b3045d55b4bb408524d2e56e6a9af15c50d602440e69f99da

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page