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 the new sigv4a 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

requests_iamauth-1.0.0.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

requests_iamauth-1.0.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file requests_iamauth-1.0.0.tar.gz.

File metadata

  • Download URL: requests_iamauth-1.0.0.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.3

File hashes

Hashes for requests_iamauth-1.0.0.tar.gz
Algorithm Hash digest
SHA256 499115cb6466e2dbd525c0e4577a81b1846efe88ce67171f46af491f75fbc49f
MD5 4869e422ca1cd68068ecbe4dc92a673e
BLAKE2b-256 115ee36ceb2524d2fe23905bd56f2e6ef7fbf545e75b73aaf65c51eac1c71707

See more details on using hashes here.

File details

Details for the file requests_iamauth-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for requests_iamauth-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e732b1e4d94549702083793c9a030616b0d1d56714e1e825fbf0907eb2b0430d
MD5 eb03164c6c18b4398231f9bcb2f7ca36
BLAKE2b-256 ee59e942841b887572693db49518ea8d18670d1fcb9323192ca2c2cf068fddc0

See more details on using hashes here.

Supported by

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