Skip to content

Commit 76bfa1d

Browse files
committed
Add authentication settings endpoint and dynamic proxy URL to clipboard
1 parent acf43e6 commit 76bfa1d

File tree

2 files changed

+50
-28
lines changed

2 files changed

+50
-28
lines changed

cloudproxy-ui/src/components/ListProxies.vue

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,20 @@
22
<div>
33
<div class="provider-section" v-for="(item, key, index) in data" :key="index">
44
<div class="provider-header">
5-
<div class="d-flex align-items-center justify-content-between">
6-
<div class="d-flex align-items-center">
7-
<div class="provider-icon-wrapper mr-2">
8-
<i :class="'bi bi-' + getProviderIcon(key)" style="font-size: 1.5rem;"></i>
9-
</div>
10-
<h2 class="mb-0">{{ formatProviderName(key) }}</h2>
5+
<div class="d-flex justify-content-between align-items-center">
6+
<div>
7+
<h2>
8+
<i :class="'bi bi-' + getProviderIcon(key)" class="mr-2"></i>
9+
{{ formatProviderName(key) }}
10+
</h2>
11+
</div>
12+
<div>
13+
<span
14+
:class="['status-badge', item.enabled ? 'status-active' : '']"
15+
>
16+
{{ item.enabled ? "Active" : "Disabled" }}
17+
</span>
1118
</div>
12-
<b-form class="scaling-control" @submit.prevent="updateProvider(key, item.scaling.min_scaling)">
13-
<div class="d-flex align-items-center">
14-
<span class="status-badge" :class="{'status-active': item.ips.length > 0}" v-b-tooltip.hover title="Number of active proxy instances">
15-
<i class="bi bi-hdd-stack mr-1"></i>
16-
{{ item.ips.length }} Active
17-
</span>
18-
<label for="sb-inline" class="mx-3">
19-
<i class="bi bi-sliders mr-1"></i>
20-
Scale to
21-
</label>
22-
<b-form-spinbutton
23-
v-model="item.scaling.min_scaling"
24-
min="0"
25-
max="100"
26-
inline
27-
@change="updateProvider(key, $event)"
28-
class="custom-spinbutton"
29-
v-b-tooltip.hover title="Set the number of proxy instances"
30-
></b-form-spinbutton>
31-
</div>
32-
</b-form>
3319
</div>
3420
</div>
3521

@@ -140,11 +126,17 @@ export default {
140126
data: {},
141127
listremove_data: [],
142128
toastCount: 0,
129+
auth: {
130+
username: '',
131+
password: '',
132+
auth_enabled: true
133+
}
143134
};
144135
},
145136
beforeMount() {
146137
this.getName();
147138
this.listremoveProxy();
139+
this.getAuthSettings();
148140
},
149141
methods: {
150142
formatProviderName(name) {
@@ -263,9 +255,20 @@ export default {
263255
appendToast: append,
264256
});
265257
},
258+
async getAuthSettings() {
259+
try {
260+
const res = await fetch("/auth");
261+
const data = await res.json();
262+
this.auth = data;
263+
} catch (error) {
264+
console.error('Failed to fetch auth settings:', error);
265+
}
266+
},
266267
copyToClipboard(ip) {
267268
// Create proxy URL with authentication
268-
const url = `http://${process.env.VUE_APP_USERNAME || 'username'}:${process.env.VUE_APP_PASSWORD || 'password'}@${ip}:8899`;
269+
const url = this.auth.auth_enabled
270+
? `http://${this.auth.username}:${this.auth.password}@${ip}:8899`
271+
: `http://${ip}:8899`;
269272
navigator.clipboard.writeText(url).then(() => {
270273
this.$bvToast.toast('Proxy address copied to clipboard', {
271274
title: 'Copied!',

cloudproxy/main.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,25 @@ class ProviderResponse(BaseModel):
324324
message: str
325325
provider: Provider
326326

327+
class AuthSettings(BaseModel):
328+
username: str
329+
password: str
330+
auth_enabled: bool = True
331+
332+
@app.get("/auth", tags=["Authentication"], response_model=AuthSettings)
333+
def get_auth_settings():
334+
"""
335+
Get the current authentication settings.
336+
337+
Returns:
338+
AuthSettings: The current username and password configuration
339+
"""
340+
return AuthSettings(
341+
username=settings.config["auth"]["username"],
342+
password=settings.config["auth"]["password"],
343+
auth_enabled=not settings.config["no_auth"]
344+
)
345+
327346
class ProviderUpdateRequest(BaseModel):
328347
min_scaling: int = Field(ge=0, description="Minimum number of proxy instances")
329348
max_scaling: int = Field(ge=0, description="Maximum number of proxy instances")

0 commit comments

Comments
 (0)