xenfra 0.2.8__tar.gz → 0.3.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.
- {xenfra-0.2.8 → xenfra-0.3.0}/PKG-INFO +84 -84
- {xenfra-0.2.8 → xenfra-0.3.0}/README.md +83 -83
- {xenfra-0.2.8 → xenfra-0.3.0}/pyproject.toml +53 -53
- {xenfra-0.2.8 → xenfra-0.3.0}/src/xenfra/commands/__init__.py +3 -3
- xenfra-0.3.0/src/xenfra/commands/auth.py +137 -0
- xenfra-0.3.0/src/xenfra/commands/auth_device.py +159 -0
- {xenfra-0.2.8 → xenfra-0.3.0}/src/xenfra/commands/deployments.py +666 -484
- {xenfra-0.2.8 → xenfra-0.3.0}/src/xenfra/commands/intelligence.py +343 -343
- {xenfra-0.2.8 → xenfra-0.3.0}/src/xenfra/commands/projects.py +204 -204
- {xenfra-0.2.8 → xenfra-0.3.0}/src/xenfra/commands/security_cmd.py +233 -233
- {xenfra-0.2.8 → xenfra-0.3.0}/src/xenfra/main.py +75 -74
- {xenfra-0.2.8 → xenfra-0.3.0}/src/xenfra/utils/__init__.py +3 -3
- {xenfra-0.2.8 → xenfra-0.3.0}/src/xenfra/utils/auth.py +243 -226
- {xenfra-0.2.8 → xenfra-0.3.0}/src/xenfra/utils/codebase.py +126 -126
- {xenfra-0.2.8 → xenfra-0.3.0}/src/xenfra/utils/config.py +363 -363
- {xenfra-0.2.8 → xenfra-0.3.0}/src/xenfra/utils/security.py +336 -336
- {xenfra-0.2.8 → xenfra-0.3.0}/src/xenfra/utils/validation.py +234 -234
- xenfra-0.2.8/src/xenfra/commands/auth.py +0 -291
- {xenfra-0.2.8 → xenfra-0.3.0}/src/xenfra/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: xenfra
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: A 'Zen Mode' infrastructure engine for Python developers.
|
|
5
5
|
Author: xenfra-cloud
|
|
6
6
|
Author-email: xenfra-cloud <xenfracloud@gmail.com>
|
|
@@ -31,86 +31,86 @@ Project-URL: Issues, https://github.com/xenfra-cloud/xenfra/issues
|
|
|
31
31
|
Provides-Extra: test
|
|
32
32
|
Description-Content-Type: text/markdown
|
|
33
33
|
|
|
34
|
-
# Xenfra CLI
|
|
35
|
-
|
|
36
|
-
## Xenfra CLI: Deploy Python Apps with Zen Mode
|
|
37
|
-
|
|
38
|
-
The Xenfra CLI is a powerful and intuitive command-line interface designed to streamline the deployment of Python applications to DigitalOcean. Built with a "Zen Mode" philosophy, it automates complex infrastructure tasks, allowing developers to focus on writing code.
|
|
39
|
-
|
|
40
|
-
### ✨ Key Features
|
|
41
|
-
|
|
42
|
-
- **Zero-Configuration Deployment:** Automatically detects your project's framework and dependencies.
|
|
43
|
-
- **AI-Powered Auto-Healing:** Diagnoses common deployment failures and suggests, or even applies, fixes automatically.
|
|
44
|
-
- **Real-time Monitoring:** View deployment status and stream live application logs directly from your terminal.
|
|
45
|
-
- **Integrated Project Management:** Easily list, view, and destroy your deployed projects.
|
|
46
|
-
- **Secure Authentication:** Uses OAuth2 PKCE flow for secure, token-based authentication.
|
|
47
|
-
|
|
48
|
-
### 🚀 Quickstart
|
|
49
|
-
|
|
50
|
-
#### 1. Installation
|
|
51
|
-
|
|
52
|
-
Install the Xenfra CLI using `uv` (recommended) or `pip`:
|
|
53
|
-
|
|
54
|
-
```bash
|
|
55
|
-
uv pip install xenfra-cli
|
|
56
|
-
# or
|
|
57
|
-
pip install xenfra-cli
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
#### 2. Authentication
|
|
61
|
-
|
|
62
|
-
Log in to your Xenfra account. This will open your web browser to complete the OAuth2 flow.
|
|
63
|
-
|
|
64
|
-
```bash
|
|
65
|
-
xenfra auth login
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
#### 3. Initialize Your Project
|
|
69
|
-
|
|
70
|
-
Navigate to your Python project's root directory and run `init`. The CLI will scan your codebase, detect its characteristics, and generate a `xenfra.yaml` configuration file.
|
|
71
|
-
|
|
72
|
-
```bash
|
|
73
|
-
cd your-python-project/
|
|
74
|
-
xenfra init
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
#### 4. Deploy Your Application
|
|
78
|
-
|
|
79
|
-
Once `xenfra.yaml` is configured, deploy your application. The CLI will handle provisioning a DigitalOcean Droplet, setting up Docker, and deploying your code.
|
|
80
|
-
|
|
81
|
-
```bash
|
|
82
|
-
xenfra deploy
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
### 📋 Usage Examples
|
|
86
|
-
|
|
87
|
-
- **Monitor Deployment Status:**
|
|
88
|
-
```bash
|
|
89
|
-
xenfra status <deployment-id>
|
|
90
|
-
```
|
|
91
|
-
- **Stream Application Logs:**
|
|
92
|
-
```bash
|
|
93
|
-
xenfra logs <deployment-id>
|
|
94
|
-
```
|
|
95
|
-
- **List Deployed Projects:**
|
|
96
|
-
```bash
|
|
97
|
-
xenfra projects list
|
|
98
|
-
```
|
|
99
|
-
- **Diagnose a Failed Deployment (AI-Powered):**
|
|
100
|
-
```bash
|
|
101
|
-
xenfra diagnose <deployment-id>
|
|
102
|
-
# Or to diagnose from a log file:
|
|
103
|
-
xenfra diagnose --logs error.log
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
### 📚 Documentation
|
|
107
|
-
|
|
108
|
-
For more detailed information, advanced configurations, and API references, please refer to the [official Xenfra Documentation](https://docs.xenfra.tech/cli) (Link will be updated upon final deployment).
|
|
109
|
-
|
|
110
|
-
### 🤝 Contributing
|
|
111
|
-
|
|
112
|
-
We welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for more details.
|
|
113
|
-
|
|
114
|
-
### 📄 License
|
|
115
|
-
|
|
116
|
-
This project is licensed under the [MIT License](LICENSE).
|
|
34
|
+
# Xenfra CLI
|
|
35
|
+
|
|
36
|
+
## Xenfra CLI: Deploy Python Apps with Zen Mode
|
|
37
|
+
|
|
38
|
+
The Xenfra CLI is a powerful and intuitive command-line interface designed to streamline the deployment of Python applications to DigitalOcean. Built with a "Zen Mode" philosophy, it automates complex infrastructure tasks, allowing developers to focus on writing code.
|
|
39
|
+
|
|
40
|
+
### ✨ Key Features
|
|
41
|
+
|
|
42
|
+
- **Zero-Configuration Deployment:** Automatically detects your project's framework and dependencies.
|
|
43
|
+
- **AI-Powered Auto-Healing:** Diagnoses common deployment failures and suggests, or even applies, fixes automatically.
|
|
44
|
+
- **Real-time Monitoring:** View deployment status and stream live application logs directly from your terminal.
|
|
45
|
+
- **Integrated Project Management:** Easily list, view, and destroy your deployed projects.
|
|
46
|
+
- **Secure Authentication:** Uses OAuth2 PKCE flow for secure, token-based authentication.
|
|
47
|
+
|
|
48
|
+
### 🚀 Quickstart
|
|
49
|
+
|
|
50
|
+
#### 1. Installation
|
|
51
|
+
|
|
52
|
+
Install the Xenfra CLI using `uv` (recommended) or `pip`:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
uv pip install xenfra-cli
|
|
56
|
+
# or
|
|
57
|
+
pip install xenfra-cli
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
#### 2. Authentication
|
|
61
|
+
|
|
62
|
+
Log in to your Xenfra account. This will open your web browser to complete the OAuth2 flow.
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
xenfra auth login
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
#### 3. Initialize Your Project
|
|
69
|
+
|
|
70
|
+
Navigate to your Python project's root directory and run `init`. The CLI will scan your codebase, detect its characteristics, and generate a `xenfra.yaml` configuration file.
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
cd your-python-project/
|
|
74
|
+
xenfra init
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
#### 4. Deploy Your Application
|
|
78
|
+
|
|
79
|
+
Once `xenfra.yaml` is configured, deploy your application. The CLI will handle provisioning a DigitalOcean Droplet, setting up Docker, and deploying your code.
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
xenfra deploy
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### 📋 Usage Examples
|
|
86
|
+
|
|
87
|
+
- **Monitor Deployment Status:**
|
|
88
|
+
```bash
|
|
89
|
+
xenfra status <deployment-id>
|
|
90
|
+
```
|
|
91
|
+
- **Stream Application Logs:**
|
|
92
|
+
```bash
|
|
93
|
+
xenfra logs <deployment-id>
|
|
94
|
+
```
|
|
95
|
+
- **List Deployed Projects:**
|
|
96
|
+
```bash
|
|
97
|
+
xenfra projects list
|
|
98
|
+
```
|
|
99
|
+
- **Diagnose a Failed Deployment (AI-Powered):**
|
|
100
|
+
```bash
|
|
101
|
+
xenfra diagnose <deployment-id>
|
|
102
|
+
# Or to diagnose from a log file:
|
|
103
|
+
xenfra diagnose --logs error.log
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### 📚 Documentation
|
|
107
|
+
|
|
108
|
+
For more detailed information, advanced configurations, and API references, please refer to the [official Xenfra Documentation](https://docs.xenfra.tech/cli) (Link will be updated upon final deployment).
|
|
109
|
+
|
|
110
|
+
### 🤝 Contributing
|
|
111
|
+
|
|
112
|
+
We welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for more details.
|
|
113
|
+
|
|
114
|
+
### 📄 License
|
|
115
|
+
|
|
116
|
+
This project is licensed under the [MIT License](LICENSE).
|
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
# Xenfra CLI
|
|
2
|
-
|
|
3
|
-
## Xenfra CLI: Deploy Python Apps with Zen Mode
|
|
4
|
-
|
|
5
|
-
The Xenfra CLI is a powerful and intuitive command-line interface designed to streamline the deployment of Python applications to DigitalOcean. Built with a "Zen Mode" philosophy, it automates complex infrastructure tasks, allowing developers to focus on writing code.
|
|
6
|
-
|
|
7
|
-
### ✨ Key Features
|
|
8
|
-
|
|
9
|
-
- **Zero-Configuration Deployment:** Automatically detects your project's framework and dependencies.
|
|
10
|
-
- **AI-Powered Auto-Healing:** Diagnoses common deployment failures and suggests, or even applies, fixes automatically.
|
|
11
|
-
- **Real-time Monitoring:** View deployment status and stream live application logs directly from your terminal.
|
|
12
|
-
- **Integrated Project Management:** Easily list, view, and destroy your deployed projects.
|
|
13
|
-
- **Secure Authentication:** Uses OAuth2 PKCE flow for secure, token-based authentication.
|
|
14
|
-
|
|
15
|
-
### 🚀 Quickstart
|
|
16
|
-
|
|
17
|
-
#### 1. Installation
|
|
18
|
-
|
|
19
|
-
Install the Xenfra CLI using `uv` (recommended) or `pip`:
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
uv pip install xenfra-cli
|
|
23
|
-
# or
|
|
24
|
-
pip install xenfra-cli
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
#### 2. Authentication
|
|
28
|
-
|
|
29
|
-
Log in to your Xenfra account. This will open your web browser to complete the OAuth2 flow.
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
xenfra auth login
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
#### 3. Initialize Your Project
|
|
36
|
-
|
|
37
|
-
Navigate to your Python project's root directory and run `init`. The CLI will scan your codebase, detect its characteristics, and generate a `xenfra.yaml` configuration file.
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
cd your-python-project/
|
|
41
|
-
xenfra init
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
#### 4. Deploy Your Application
|
|
45
|
-
|
|
46
|
-
Once `xenfra.yaml` is configured, deploy your application. The CLI will handle provisioning a DigitalOcean Droplet, setting up Docker, and deploying your code.
|
|
47
|
-
|
|
48
|
-
```bash
|
|
49
|
-
xenfra deploy
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
### 📋 Usage Examples
|
|
53
|
-
|
|
54
|
-
- **Monitor Deployment Status:**
|
|
55
|
-
```bash
|
|
56
|
-
xenfra status <deployment-id>
|
|
57
|
-
```
|
|
58
|
-
- **Stream Application Logs:**
|
|
59
|
-
```bash
|
|
60
|
-
xenfra logs <deployment-id>
|
|
61
|
-
```
|
|
62
|
-
- **List Deployed Projects:**
|
|
63
|
-
```bash
|
|
64
|
-
xenfra projects list
|
|
65
|
-
```
|
|
66
|
-
- **Diagnose a Failed Deployment (AI-Powered):**
|
|
67
|
-
```bash
|
|
68
|
-
xenfra diagnose <deployment-id>
|
|
69
|
-
# Or to diagnose from a log file:
|
|
70
|
-
xenfra diagnose --logs error.log
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
### 📚 Documentation
|
|
74
|
-
|
|
75
|
-
For more detailed information, advanced configurations, and API references, please refer to the [official Xenfra Documentation](https://docs.xenfra.tech/cli) (Link will be updated upon final deployment).
|
|
76
|
-
|
|
77
|
-
### 🤝 Contributing
|
|
78
|
-
|
|
79
|
-
We welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for more details.
|
|
80
|
-
|
|
81
|
-
### 📄 License
|
|
82
|
-
|
|
83
|
-
This project is licensed under the [MIT License](LICENSE).
|
|
1
|
+
# Xenfra CLI
|
|
2
|
+
|
|
3
|
+
## Xenfra CLI: Deploy Python Apps with Zen Mode
|
|
4
|
+
|
|
5
|
+
The Xenfra CLI is a powerful and intuitive command-line interface designed to streamline the deployment of Python applications to DigitalOcean. Built with a "Zen Mode" philosophy, it automates complex infrastructure tasks, allowing developers to focus on writing code.
|
|
6
|
+
|
|
7
|
+
### ✨ Key Features
|
|
8
|
+
|
|
9
|
+
- **Zero-Configuration Deployment:** Automatically detects your project's framework and dependencies.
|
|
10
|
+
- **AI-Powered Auto-Healing:** Diagnoses common deployment failures and suggests, or even applies, fixes automatically.
|
|
11
|
+
- **Real-time Monitoring:** View deployment status and stream live application logs directly from your terminal.
|
|
12
|
+
- **Integrated Project Management:** Easily list, view, and destroy your deployed projects.
|
|
13
|
+
- **Secure Authentication:** Uses OAuth2 PKCE flow for secure, token-based authentication.
|
|
14
|
+
|
|
15
|
+
### 🚀 Quickstart
|
|
16
|
+
|
|
17
|
+
#### 1. Installation
|
|
18
|
+
|
|
19
|
+
Install the Xenfra CLI using `uv` (recommended) or `pip`:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
uv pip install xenfra-cli
|
|
23
|
+
# or
|
|
24
|
+
pip install xenfra-cli
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
#### 2. Authentication
|
|
28
|
+
|
|
29
|
+
Log in to your Xenfra account. This will open your web browser to complete the OAuth2 flow.
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
xenfra auth login
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
#### 3. Initialize Your Project
|
|
36
|
+
|
|
37
|
+
Navigate to your Python project's root directory and run `init`. The CLI will scan your codebase, detect its characteristics, and generate a `xenfra.yaml` configuration file.
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
cd your-python-project/
|
|
41
|
+
xenfra init
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
#### 4. Deploy Your Application
|
|
45
|
+
|
|
46
|
+
Once `xenfra.yaml` is configured, deploy your application. The CLI will handle provisioning a DigitalOcean Droplet, setting up Docker, and deploying your code.
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
xenfra deploy
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### 📋 Usage Examples
|
|
53
|
+
|
|
54
|
+
- **Monitor Deployment Status:**
|
|
55
|
+
```bash
|
|
56
|
+
xenfra status <deployment-id>
|
|
57
|
+
```
|
|
58
|
+
- **Stream Application Logs:**
|
|
59
|
+
```bash
|
|
60
|
+
xenfra logs <deployment-id>
|
|
61
|
+
```
|
|
62
|
+
- **List Deployed Projects:**
|
|
63
|
+
```bash
|
|
64
|
+
xenfra projects list
|
|
65
|
+
```
|
|
66
|
+
- **Diagnose a Failed Deployment (AI-Powered):**
|
|
67
|
+
```bash
|
|
68
|
+
xenfra diagnose <deployment-id>
|
|
69
|
+
# Or to diagnose from a log file:
|
|
70
|
+
xenfra diagnose --logs error.log
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### 📚 Documentation
|
|
74
|
+
|
|
75
|
+
For more detailed information, advanced configurations, and API references, please refer to the [official Xenfra Documentation](https://docs.xenfra.tech/cli) (Link will be updated upon final deployment).
|
|
76
|
+
|
|
77
|
+
### 🤝 Contributing
|
|
78
|
+
|
|
79
|
+
We welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for more details.
|
|
80
|
+
|
|
81
|
+
### 📄 License
|
|
82
|
+
|
|
83
|
+
This project is licensed under the [MIT License](LICENSE).
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
[project]
|
|
2
|
-
name = "xenfra"
|
|
3
|
-
version = "0.
|
|
4
|
-
description = "A 'Zen Mode' infrastructure engine for Python developers."
|
|
5
|
-
readme = "README.md"
|
|
6
|
-
authors = [
|
|
7
|
-
{ name = "xenfra-cloud", email = "xenfracloud@gmail.com" }
|
|
8
|
-
]
|
|
9
|
-
|
|
10
|
-
classifiers = [
|
|
11
|
-
"Programming Language :: Python :: 3",
|
|
12
|
-
"License :: OSI Approved :: MIT License",
|
|
13
|
-
"Operating System :: OS Independent",
|
|
14
|
-
"Development Status :: 3 - Alpha",
|
|
15
|
-
"Intended Audience :: Developers",
|
|
16
|
-
"Topic :: Software Development :: Build Tools",
|
|
17
|
-
"Topic :: System :: Systems Administration",
|
|
18
|
-
]
|
|
19
|
-
|
|
20
|
-
dependencies = [
|
|
21
|
-
"click>=8.1.7",
|
|
22
|
-
"rich>=14.2.0",
|
|
23
|
-
"sqlmodel>=0.0.16",
|
|
24
|
-
"python-digitalocean>=1.17.0",
|
|
25
|
-
"python-dotenv>=1.2.1",
|
|
26
|
-
"pyyaml>=6.0.1",
|
|
27
|
-
"fabric>=3.2.2",
|
|
28
|
-
"xenfra-sdk",
|
|
29
|
-
"httpx>=0.27.0",
|
|
30
|
-
"keyring>=25.7.0",
|
|
31
|
-
"keyrings.alt>=5.0.2",
|
|
32
|
-
"tenacity>=8.2.3", # For retry logic
|
|
33
|
-
]
|
|
34
|
-
requires-python = ">=3.13"
|
|
35
|
-
|
|
36
|
-
[tool.uv.sources]
|
|
37
|
-
xenfra-sdk = { workspace = true }
|
|
38
|
-
|
|
39
|
-
[project.urls]
|
|
40
|
-
Homepage = "https://github.com/xenfra-cloud/xenfra"
|
|
41
|
-
Issues = "https://github.com/xenfra-cloud/xenfra/issues"
|
|
42
|
-
|
|
43
|
-
[project.optional-dependencies]
|
|
44
|
-
test = [
|
|
45
|
-
"pytest>=8.0.0",
|
|
46
|
-
"pytest-mock>=3.12.0",
|
|
47
|
-
]
|
|
48
|
-
|
|
49
|
-
[project.scripts]
|
|
50
|
-
xenfra = "xenfra.main:main"
|
|
51
|
-
|
|
52
|
-
[build-system]
|
|
53
|
-
requires = ["uv_build>=0.9.18,<0.10.0"]
|
|
1
|
+
[project]
|
|
2
|
+
name = "xenfra"
|
|
3
|
+
version = "0.3.0"
|
|
4
|
+
description = "A 'Zen Mode' infrastructure engine for Python developers."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
authors = [
|
|
7
|
+
{ name = "xenfra-cloud", email = "xenfracloud@gmail.com" }
|
|
8
|
+
]
|
|
9
|
+
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Programming Language :: Python :: 3",
|
|
12
|
+
"License :: OSI Approved :: MIT License",
|
|
13
|
+
"Operating System :: OS Independent",
|
|
14
|
+
"Development Status :: 3 - Alpha",
|
|
15
|
+
"Intended Audience :: Developers",
|
|
16
|
+
"Topic :: Software Development :: Build Tools",
|
|
17
|
+
"Topic :: System :: Systems Administration",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
dependencies = [
|
|
21
|
+
"click>=8.1.7",
|
|
22
|
+
"rich>=14.2.0",
|
|
23
|
+
"sqlmodel>=0.0.16",
|
|
24
|
+
"python-digitalocean>=1.17.0",
|
|
25
|
+
"python-dotenv>=1.2.1",
|
|
26
|
+
"pyyaml>=6.0.1",
|
|
27
|
+
"fabric>=3.2.2",
|
|
28
|
+
"xenfra-sdk",
|
|
29
|
+
"httpx>=0.27.0",
|
|
30
|
+
"keyring>=25.7.0",
|
|
31
|
+
"keyrings.alt>=5.0.2",
|
|
32
|
+
"tenacity>=8.2.3", # For retry logic
|
|
33
|
+
]
|
|
34
|
+
requires-python = ">=3.13"
|
|
35
|
+
|
|
36
|
+
[tool.uv.sources]
|
|
37
|
+
xenfra-sdk = { workspace = true }
|
|
38
|
+
|
|
39
|
+
[project.urls]
|
|
40
|
+
Homepage = "https://github.com/xenfra-cloud/xenfra"
|
|
41
|
+
Issues = "https://github.com/xenfra-cloud/xenfra/issues"
|
|
42
|
+
|
|
43
|
+
[project.optional-dependencies]
|
|
44
|
+
test = [
|
|
45
|
+
"pytest>=8.0.0",
|
|
46
|
+
"pytest-mock>=3.12.0",
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
[project.scripts]
|
|
50
|
+
xenfra = "xenfra.main:main"
|
|
51
|
+
|
|
52
|
+
[build-system]
|
|
53
|
+
requires = ["uv_build>=0.9.18,<0.10.0"]
|
|
54
54
|
build-backend = "uv_build"
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"""
|
|
2
|
-
CLI command modules for Xenfra.
|
|
3
|
-
"""
|
|
1
|
+
"""
|
|
2
|
+
CLI command modules for Xenfra.
|
|
3
|
+
"""
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Authentication commands for Xenfra CLI.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import base64
|
|
6
|
+
import hashlib
|
|
7
|
+
import secrets
|
|
8
|
+
import urllib.parse
|
|
9
|
+
import webbrowser
|
|
10
|
+
from http.server import HTTPServer
|
|
11
|
+
|
|
12
|
+
import click
|
|
13
|
+
import httpx
|
|
14
|
+
import keyring
|
|
15
|
+
from rich.console import Console
|
|
16
|
+
from tenacity import (
|
|
17
|
+
retry,
|
|
18
|
+
retry_if_exception_type,
|
|
19
|
+
stop_after_attempt,
|
|
20
|
+
wait_exponential,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
from ..utils.auth import (
|
|
24
|
+
API_BASE_URL,
|
|
25
|
+
CLI_CLIENT_ID,
|
|
26
|
+
CLI_LOCAL_SERVER_END_PORT,
|
|
27
|
+
CLI_LOCAL_SERVER_START_PORT,
|
|
28
|
+
CLI_REDIRECT_PATH,
|
|
29
|
+
SERVICE_ID,
|
|
30
|
+
AuthCallbackHandler,
|
|
31
|
+
clear_tokens,
|
|
32
|
+
get_auth_token,
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
console = Console()
|
|
36
|
+
|
|
37
|
+
# HTTP request timeout (30 seconds)
|
|
38
|
+
HTTP_TIMEOUT = 30.0
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@click.group()
|
|
42
|
+
def auth():
|
|
43
|
+
"""Authentication commands (login, logout, whoami)."""
|
|
44
|
+
pass
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
@retry(
|
|
48
|
+
stop=stop_after_attempt(3),
|
|
49
|
+
wait=wait_exponential(multiplier=1, min=2, max=10),
|
|
50
|
+
retry=retry_if_exception_type((httpx.TimeoutException, httpx.NetworkError)),
|
|
51
|
+
reraise=True,
|
|
52
|
+
)
|
|
53
|
+
def _exchange_code_for_tokens_with_retry(code: str, code_verifier: str, redirect_uri: str) -> dict:
|
|
54
|
+
"""
|
|
55
|
+
Exchange authorization code for tokens with retry logic.
|
|
56
|
+
|
|
57
|
+
Returns token data dictionary.
|
|
58
|
+
"""
|
|
59
|
+
with httpx.Client(timeout=HTTP_TIMEOUT) as client:
|
|
60
|
+
response = client.post(
|
|
61
|
+
f"{API_BASE_URL}/auth/token",
|
|
62
|
+
data={
|
|
63
|
+
"grant_type": "authorization_code",
|
|
64
|
+
"client_id": CLI_CLIENT_ID,
|
|
65
|
+
"code": code,
|
|
66
|
+
"code_verifier": code_verifier,
|
|
67
|
+
"redirect_uri": redirect_uri,
|
|
68
|
+
},
|
|
69
|
+
headers={"Accept": "application/json"},
|
|
70
|
+
)
|
|
71
|
+
response.raise_for_status()
|
|
72
|
+
|
|
73
|
+
# Safe JSON parsing with content-type check
|
|
74
|
+
content_type = response.headers.get("content-type", "")
|
|
75
|
+
if "application/json" not in content_type:
|
|
76
|
+
raise ValueError(f"Expected JSON response, got {content_type}")
|
|
77
|
+
|
|
78
|
+
try:
|
|
79
|
+
token_data = response.json()
|
|
80
|
+
except (ValueError, TypeError) as e:
|
|
81
|
+
raise ValueError(f"Failed to parse JSON response: {e}")
|
|
82
|
+
|
|
83
|
+
return token_data
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
@auth.command()
|
|
87
|
+
def login():
|
|
88
|
+
"""Login to Xenfra using Device Authorization Flow (like GitHub CLI, Claude Code)."""
|
|
89
|
+
from .auth_device import device_login
|
|
90
|
+
device_login()
|
|
91
|
+
|
|
92
|
+
# Removed old PKCE flow - now using Device Authorization Flow
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
@auth.command()
|
|
96
|
+
def logout():
|
|
97
|
+
"""Logout and clear stored tokens."""
|
|
98
|
+
try:
|
|
99
|
+
clear_tokens()
|
|
100
|
+
console.print("[bold green]Logged out successfully.[/bold green]")
|
|
101
|
+
except Exception as e:
|
|
102
|
+
console.print(f"[yellow]Warning: Error during logout: {e}[/yellow]")
|
|
103
|
+
console.print("[dim]Tokens may still be stored in keyring.[/dim]")
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
@auth.command()
|
|
107
|
+
@click.option("--token", is_flag=True, help="Show access token")
|
|
108
|
+
def whoami(token):
|
|
109
|
+
"""Show current authenticated user."""
|
|
110
|
+
access_token = get_auth_token()
|
|
111
|
+
|
|
112
|
+
if not access_token:
|
|
113
|
+
console.print("[bold red]Not logged in. Run 'xenfra login' first.[/bold red]")
|
|
114
|
+
return
|
|
115
|
+
|
|
116
|
+
try:
|
|
117
|
+
from jose import jwt
|
|
118
|
+
|
|
119
|
+
# For display purposes only, in a CLI context where the token has just
|
|
120
|
+
# been retrieved from a secure source (keyring), we can disable
|
|
121
|
+
# signature verification.
|
|
122
|
+
#
|
|
123
|
+
# SECURITY BEST PRACTICE: In a real application, especially a server,
|
|
124
|
+
# you would fetch the public key from the SSO's JWKS endpoint and
|
|
125
|
+
# fully verify the token's signature to ensure its integrity.
|
|
126
|
+
claims = jwt.decode(
|
|
127
|
+
access_token, options={"verify_signature": False} # OK for local display
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
console.print("[bold green]Logged in as:[/bold green]")
|
|
131
|
+
console.print(f" User ID: {claims.get('sub')}")
|
|
132
|
+
console.print(f" Email: {claims.get('email', 'N/A')}")
|
|
133
|
+
|
|
134
|
+
if token:
|
|
135
|
+
console.print(f"\n[dim]Access Token:[/dim]\n{access_token}")
|
|
136
|
+
except Exception as e:
|
|
137
|
+
console.print(f"[bold red]Failed to decode token: {e}[/bold red]")
|