Skip to main content

Performs authentication for Google Cloud Identity Aware Proxy from a service account

Project description

Google IAP authentication Upload Python Package

codecov

This module contains a helper class to make requests to an app running behind a Google Identity-Aware Proxy. The code was obtained from the Google Programmatic authentication document.

Install

pip install iap-auth

Usage

With application default credentials

If running outside Google Cloud Platform you need to specify env var GOOGLE_APPLICATION_CREDENTIALS to point to your authorized service account.

from iap_auth import IapClient

CLIENT_ID = '<your-project-client-id>.apps.googleusercontent.com'
URL = 'https://your-iap-protected-website.com.br'
METHOD = 'GET'
kwargs = {}

client = IapClient(CLIENT_ID)
resp = client.make_iap_request(URL, method=METHOD, **kwargs)

# resp is a requests.Response object.

Authenticating a user account

This way users do not need to have a service account or Google SDK installed. You'll need to create an OAuth 2.0 client ID and then use this lib as follows:

from iap_auth.user_client import UserAuth, UserIapClient

OAUTH_ID = "<desktop-app-oauth-id>.googleusercontent.com"
OAUTH_SECRET = "z6..desktop-app-oauth-secret..Ys1"
KEY_PATH = "/where/to/store/your/user-credentials.json"
IAP_OAUTH_ID = '<your-project-iap-client-id>.apps.googleusercontent.com'

URL = 'https://your-iap-protected-website.com.br'

user_auth = UserAuth(OAUTH_ID, OAUTH_SECRET, KEY_PATH)
client = UserIapClient(user_auth, IAP_OAUTH_ID)
resp = client.make_iap_request(URL, method=METHOD)

# resp is a requests.Response object.

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

iap-auth-0.2.2.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

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

iap_auth-0.2.2-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file iap-auth-0.2.2.tar.gz.

File metadata

  • Download URL: iap-auth-0.2.2.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for iap-auth-0.2.2.tar.gz
Algorithm Hash digest
SHA256 4b54948597d8735e52f23a3214c65f614c350b3108531b609d61fd59c4815453
MD5 161f917060653cdd9bbc483739d5bf2f
BLAKE2b-256 aa6f901f5a17e55b67e46088a28e31affa82924a1f3879ada15f1c9e3a11c7b9

See more details on using hashes here.

File details

Details for the file iap_auth-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: iap_auth-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for iap_auth-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cd0425dc8c790e6909afc0a2bcde7613ceb2ed27af536ec0e59beeccf5523011
MD5 a54d271ebc65185ee3d8de757e50dad9
BLAKE2b-256 78085fb63375b699f977fe1a88d3f855dfde773dafbf0c6d94255443d804f56c

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