Python module for interacting with Microsoft ADFS and OIDC for authentication and authorization, simplified, type-safe and production-ready.
Install the module using pip
pip install pyadfsSee pyproject.toml for more information and changelog.md for updates.
It is recommended that you read the microsoft docs for foundational knowledge on ADFS authentication.
See microsoft docs and OWASP regarding ADFS best practices.
all methods have matching async functions and classes for use in async environments.
from pyadfs import ADFSClient, TokenModel, generate_token
raw_token = generate_token(
grant_type="password",
username="didi45R@example.local",
password="top-secret",
)
client = ADFSClient() # Use env variables or pass vars directly at init (see config.py)
token_model = client.validate_token(raw_token.access_token)
upn = token_model.user_principle_name
email = token_model.email_address
print(f"{upn}'s token expires at: {token_model.exp_readable_timestamp}")- jwt.io (jwt playground)
- JWT RFC7519
- microsoft example openid-configuration
Created by Yedidya.R
Copyright © Yedidya Rosenstark. All rights reserved.