passmanai 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 PassmanAI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,91 @@
1
+ Metadata-Version: 2.4
2
+ Name: passmanai
3
+ Version: 0.1.0
4
+ Summary: Official Python SDK for PassmanAI OIDC Authentication
5
+ Author-email: PassmanAI <support@passmanai.com>
6
+ Project-URL: Homepage, https://passmanai.com
7
+ Project-URL: Bug Tracker, https://github.com/AshishKumarJena/passmanai-python-sdk/issues
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.8
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: Authlib>=1.3.0
15
+ Requires-Dist: requests>=2.31.0
16
+ Dynamic: license-file
17
+
18
+ # PassmanAI Python SDK
19
+
20
+ > Official Python SDK for integrating **"Sign in with Passman"** into any Python web framework (FastAPI, Django, Flask, etc.).
21
+
22
+ PassmanAI is a decentralized, post-quantum password manager with zero-knowledge architecture. This SDK provides a robust, PKCE-secured OpenID Connect (OIDC) client that makes it trivial to authenticate users via Passman.
23
+
24
+ ## Quick Start
25
+
26
+ ### 1. Install
27
+
28
+ ```bash
29
+ pip install passmanai
30
+ ```
31
+
32
+ ### 2. Configure Environment Variables
33
+
34
+ Set your Passman API credentials in your environment:
35
+
36
+ ```env
37
+ PASSMAN_CLIENT_ID=your_client_id
38
+ PASSMAN_CLIENT_SECRET=your_client_secret
39
+ PASSMAN_REDIRECT_URI=http://localhost:8000/auth/callback
40
+ PASSMAN_ISSUER_URL=http://localhost:4010
41
+ ```
42
+
43
+ > Get your client credentials by registering an OIDC client in your [PassmanAI dashboard](https://passmanai.com).
44
+
45
+ ### 3. Basic Usage (Framework Agnostic)
46
+
47
+ The SDK provides a `PassmanClient` that handles OIDC discovery, PKCE generation, and token exchange.
48
+
49
+ ```python
50
+ from passmanai import PassmanClient
51
+
52
+ # Initialize the client (automatically loads from env vars)
53
+ passman = PassmanClient()
54
+
55
+ # 1. Generate the authorization URL and PKCE state
56
+ auth_url, state, code_verifier = passman.get_authorization_url()
57
+
58
+ # Save `state` and `code_verifier` in your session, then redirect the user to `auth_url`.
59
+ # ... user logs in on Passman and gets redirected to your callback ...
60
+
61
+ # 2. Exchange the authorization code for a token and user profile
62
+ # In your callback route, reconstruct the full URL requested:
63
+ callback_url = "http://localhost:8000/auth/callback?code=...&state=..."
64
+
65
+ profile, tokens = passman.fetch_user_profile(
66
+ authorization_response_url=callback_url,
67
+ state=saved_state_from_session,
68
+ code_verifier=saved_code_verifier_from_session
69
+ )
70
+
71
+ print(f"Logged in as: {profile['preferred_username']} (ID: {profile['sub']})")
72
+ ```
73
+
74
+ ## Advanced Configuration
75
+
76
+ You can explicitly pass credentials if you prefer not to use environment variables:
77
+
78
+ ```python
79
+ passman = PassmanClient(
80
+ client_id="your_client_id",
81
+ client_secret="your_client_secret",
82
+ redirect_uri="https://myapp.com/auth/callback",
83
+ issuer_url="https://passmanai.com" # Defaults to https://passmanai.com if not set
84
+ )
85
+ ```
86
+
87
+ ## Security
88
+
89
+ - **PKCE enforced** — Prevents authorization code interception attacks.
90
+ - **State parameter** — Protects against CSRF attacks.
91
+ - Built on top of **Authlib**, the industry standard for Python OAuth/OIDC.
@@ -0,0 +1,74 @@
1
+ # PassmanAI Python SDK
2
+
3
+ > Official Python SDK for integrating **"Sign in with Passman"** into any Python web framework (FastAPI, Django, Flask, etc.).
4
+
5
+ PassmanAI is a decentralized, post-quantum password manager with zero-knowledge architecture. This SDK provides a robust, PKCE-secured OpenID Connect (OIDC) client that makes it trivial to authenticate users via Passman.
6
+
7
+ ## Quick Start
8
+
9
+ ### 1. Install
10
+
11
+ ```bash
12
+ pip install passmanai
13
+ ```
14
+
15
+ ### 2. Configure Environment Variables
16
+
17
+ Set your Passman API credentials in your environment:
18
+
19
+ ```env
20
+ PASSMAN_CLIENT_ID=your_client_id
21
+ PASSMAN_CLIENT_SECRET=your_client_secret
22
+ PASSMAN_REDIRECT_URI=http://localhost:8000/auth/callback
23
+ PASSMAN_ISSUER_URL=http://localhost:4010
24
+ ```
25
+
26
+ > Get your client credentials by registering an OIDC client in your [PassmanAI dashboard](https://passmanai.com).
27
+
28
+ ### 3. Basic Usage (Framework Agnostic)
29
+
30
+ The SDK provides a `PassmanClient` that handles OIDC discovery, PKCE generation, and token exchange.
31
+
32
+ ```python
33
+ from passmanai import PassmanClient
34
+
35
+ # Initialize the client (automatically loads from env vars)
36
+ passman = PassmanClient()
37
+
38
+ # 1. Generate the authorization URL and PKCE state
39
+ auth_url, state, code_verifier = passman.get_authorization_url()
40
+
41
+ # Save `state` and `code_verifier` in your session, then redirect the user to `auth_url`.
42
+ # ... user logs in on Passman and gets redirected to your callback ...
43
+
44
+ # 2. Exchange the authorization code for a token and user profile
45
+ # In your callback route, reconstruct the full URL requested:
46
+ callback_url = "http://localhost:8000/auth/callback?code=...&state=..."
47
+
48
+ profile, tokens = passman.fetch_user_profile(
49
+ authorization_response_url=callback_url,
50
+ state=saved_state_from_session,
51
+ code_verifier=saved_code_verifier_from_session
52
+ )
53
+
54
+ print(f"Logged in as: {profile['preferred_username']} (ID: {profile['sub']})")
55
+ ```
56
+
57
+ ## Advanced Configuration
58
+
59
+ You can explicitly pass credentials if you prefer not to use environment variables:
60
+
61
+ ```python
62
+ passman = PassmanClient(
63
+ client_id="your_client_id",
64
+ client_secret="your_client_secret",
65
+ redirect_uri="https://myapp.com/auth/callback",
66
+ issuer_url="https://passmanai.com" # Defaults to https://passmanai.com if not set
67
+ )
68
+ ```
69
+
70
+ ## Security
71
+
72
+ - **PKCE enforced** — Prevents authorization code interception attacks.
73
+ - **State parameter** — Protects against CSRF attacks.
74
+ - Built on top of **Authlib**, the industry standard for Python OAuth/OIDC.
@@ -0,0 +1,3 @@
1
+ from .client import PassmanClient
2
+
3
+ __all__ = ["PassmanClient"]
@@ -0,0 +1,108 @@
1
+ import os
2
+ from typing import Dict, Tuple, Optional
3
+ import requests
4
+ from authlib.integrations.requests_client import OAuth2Session
5
+
6
+ class PassmanClient:
7
+ """
8
+ PassmanClient is a Python SDK for integrating 'Sign in with Passman' via OIDC.
9
+ It automatically discovers endpoints and manages PKCE for maximum security.
10
+ """
11
+
12
+ def __init__(
13
+ self,
14
+ client_id: Optional[str] = None,
15
+ client_secret: Optional[str] = None,
16
+ redirect_uri: Optional[str] = None,
17
+ issuer_url: Optional[str] = None,
18
+ ):
19
+ self.client_id = client_id or os.environ.get("PASSMAN_CLIENT_ID")
20
+ self.client_secret = client_secret or os.environ.get("PASSMAN_CLIENT_SECRET")
21
+ self.redirect_uri = redirect_uri or os.environ.get("PASSMAN_REDIRECT_URI")
22
+ self.issuer_url = issuer_url or os.environ.get("PASSMAN_ISSUER_URL", "https://passmanai.com")
23
+
24
+ if not self.client_id or not self.client_secret:
25
+ raise ValueError("PASSMAN_CLIENT_ID and PASSMAN_CLIENT_SECRET must be provided.")
26
+ if not self.redirect_uri:
27
+ raise ValueError("PASSMAN_REDIRECT_URI must be provided.")
28
+
29
+ # Strip trailing slash from issuer
30
+ if self.issuer_url.endswith("/"):
31
+ self.issuer_url = self.issuer_url[:-1]
32
+
33
+ # Discover endpoints from PassmanAI
34
+ self._discover_endpoints()
35
+
36
+ # Initialize the Authlib session
37
+ self.session = OAuth2Session(
38
+ client_id=self.client_id,
39
+ client_secret=self.client_secret,
40
+ redirect_uri=self.redirect_uri,
41
+ scope="openid profile email"
42
+ )
43
+
44
+ def _discover_endpoints(self):
45
+ """Fetches the OIDC configuration from the well-known URL."""
46
+ well_known_url = f"{self.issuer_url}/api/oidc/.well-known/openid-configuration"
47
+ response = requests.get(well_known_url)
48
+ response.raise_for_status()
49
+ config = response.json()
50
+
51
+ self.authorization_endpoint = config.get("authorization_endpoint")
52
+ self.token_endpoint = config.get("token_endpoint")
53
+ self.userinfo_endpoint = config.get("userinfo_endpoint")
54
+
55
+ if not all([self.authorization_endpoint, self.token_endpoint, self.userinfo_endpoint]):
56
+ raise RuntimeError("Failed to discover all required endpoints from the issuer.")
57
+
58
+ def get_authorization_url(self) -> Tuple[str, str, str]:
59
+ """
60
+ Generates the URL to redirect the user to PassmanAI for login.
61
+
62
+ Returns:
63
+ Tuple containing:
64
+ - auth_url (str): The URL to redirect the user to.
65
+ - state (str): A random string to prevent CSRF. Must be saved in session.
66
+ - code_verifier (str): The PKCE verifier. Must be saved in session.
67
+ """
68
+ # PKCE code challenge method S256 is recommended by default in Authlib
69
+ auth_url, state = self.session.create_authorization_url(self.authorization_endpoint)
70
+ code_verifier = self.session.code_verifier
71
+
72
+ return auth_url, state, code_verifier
73
+
74
+ def fetch_user_profile(
75
+ self,
76
+ authorization_response_url: str,
77
+ state: str,
78
+ code_verifier: str
79
+ ) -> Tuple[Dict, Dict]:
80
+ """
81
+ Exchanges the authorization code for tokens and fetches the user profile.
82
+
83
+ Args:
84
+ authorization_response_url: The full URL the user was redirected to after login.
85
+ state: The state string generated by get_authorization_url().
86
+ code_verifier: The PKCE verifier generated by get_authorization_url().
87
+
88
+ Returns:
89
+ Tuple containing:
90
+ - profile (Dict): The user's profile information.
91
+ - tokens (Dict): The OIDC tokens (access_token, id_token, etc).
92
+ """
93
+ # Re-initialize state and PKCE verifier into the session before fetching token
94
+ self.session.state = state
95
+ self.session.code_verifier = code_verifier
96
+
97
+ # Exchange code for tokens
98
+ tokens = self.session.fetch_token(
99
+ self.token_endpoint,
100
+ authorization_response=authorization_response_url,
101
+ )
102
+
103
+ # Fetch the user profile using the access token
104
+ profile_response = self.session.get(self.userinfo_endpoint)
105
+ profile_response.raise_for_status()
106
+ profile = profile_response.json()
107
+
108
+ return profile, tokens
@@ -0,0 +1,91 @@
1
+ Metadata-Version: 2.4
2
+ Name: passmanai
3
+ Version: 0.1.0
4
+ Summary: Official Python SDK for PassmanAI OIDC Authentication
5
+ Author-email: PassmanAI <support@passmanai.com>
6
+ Project-URL: Homepage, https://passmanai.com
7
+ Project-URL: Bug Tracker, https://github.com/AshishKumarJena/passmanai-python-sdk/issues
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.8
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: Authlib>=1.3.0
15
+ Requires-Dist: requests>=2.31.0
16
+ Dynamic: license-file
17
+
18
+ # PassmanAI Python SDK
19
+
20
+ > Official Python SDK for integrating **"Sign in with Passman"** into any Python web framework (FastAPI, Django, Flask, etc.).
21
+
22
+ PassmanAI is a decentralized, post-quantum password manager with zero-knowledge architecture. This SDK provides a robust, PKCE-secured OpenID Connect (OIDC) client that makes it trivial to authenticate users via Passman.
23
+
24
+ ## Quick Start
25
+
26
+ ### 1. Install
27
+
28
+ ```bash
29
+ pip install passmanai
30
+ ```
31
+
32
+ ### 2. Configure Environment Variables
33
+
34
+ Set your Passman API credentials in your environment:
35
+
36
+ ```env
37
+ PASSMAN_CLIENT_ID=your_client_id
38
+ PASSMAN_CLIENT_SECRET=your_client_secret
39
+ PASSMAN_REDIRECT_URI=http://localhost:8000/auth/callback
40
+ PASSMAN_ISSUER_URL=http://localhost:4010
41
+ ```
42
+
43
+ > Get your client credentials by registering an OIDC client in your [PassmanAI dashboard](https://passmanai.com).
44
+
45
+ ### 3. Basic Usage (Framework Agnostic)
46
+
47
+ The SDK provides a `PassmanClient` that handles OIDC discovery, PKCE generation, and token exchange.
48
+
49
+ ```python
50
+ from passmanai import PassmanClient
51
+
52
+ # Initialize the client (automatically loads from env vars)
53
+ passman = PassmanClient()
54
+
55
+ # 1. Generate the authorization URL and PKCE state
56
+ auth_url, state, code_verifier = passman.get_authorization_url()
57
+
58
+ # Save `state` and `code_verifier` in your session, then redirect the user to `auth_url`.
59
+ # ... user logs in on Passman and gets redirected to your callback ...
60
+
61
+ # 2. Exchange the authorization code for a token and user profile
62
+ # In your callback route, reconstruct the full URL requested:
63
+ callback_url = "http://localhost:8000/auth/callback?code=...&state=..."
64
+
65
+ profile, tokens = passman.fetch_user_profile(
66
+ authorization_response_url=callback_url,
67
+ state=saved_state_from_session,
68
+ code_verifier=saved_code_verifier_from_session
69
+ )
70
+
71
+ print(f"Logged in as: {profile['preferred_username']} (ID: {profile['sub']})")
72
+ ```
73
+
74
+ ## Advanced Configuration
75
+
76
+ You can explicitly pass credentials if you prefer not to use environment variables:
77
+
78
+ ```python
79
+ passman = PassmanClient(
80
+ client_id="your_client_id",
81
+ client_secret="your_client_secret",
82
+ redirect_uri="https://myapp.com/auth/callback",
83
+ issuer_url="https://passmanai.com" # Defaults to https://passmanai.com if not set
84
+ )
85
+ ```
86
+
87
+ ## Security
88
+
89
+ - **PKCE enforced** — Prevents authorization code interception attacks.
90
+ - **State parameter** — Protects against CSRF attacks.
91
+ - Built on top of **Authlib**, the industry standard for Python OAuth/OIDC.
@@ -0,0 +1,10 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ passmanai/__init__.py
5
+ passmanai/client.py
6
+ passmanai.egg-info/PKG-INFO
7
+ passmanai.egg-info/SOURCES.txt
8
+ passmanai.egg-info/dependency_links.txt
9
+ passmanai.egg-info/requires.txt
10
+ passmanai.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ Authlib>=1.3.0
2
+ requests>=2.31.0
@@ -0,0 +1 @@
1
+ passmanai
@@ -0,0 +1,26 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "passmanai"
7
+ version = "0.1.0"
8
+ authors = [
9
+ { name="PassmanAI", email="support@passmanai.com" },
10
+ ]
11
+ description = "Official Python SDK for PassmanAI OIDC Authentication"
12
+ readme = "README.md"
13
+ requires-python = ">=3.8"
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "License :: OSI Approved :: MIT License",
17
+ "Operating System :: OS Independent",
18
+ ]
19
+ dependencies = [
20
+ "Authlib>=1.3.0",
21
+ "requests>=2.31.0"
22
+ ]
23
+
24
+ [project.urls]
25
+ "Homepage" = "https://passmanai.com"
26
+ "Bug Tracker" = "https://github.com/AshishKumarJena/passmanai-python-sdk/issues"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+