grimmory auth
This commit is contained in:
+2
-10
@@ -74,18 +74,10 @@ def place_book(
|
|||||||
def test_connection(url: str, user: str, password: str) -> tuple[bool, str]:
|
def test_connection(url: str, user: str, password: str) -> tuple[bool, str]:
|
||||||
base = url.rstrip("/")
|
base = url.rstrip("/")
|
||||||
try:
|
try:
|
||||||
# Health check (no auth required)
|
|
||||||
r = requests.get(base + "/api/v1/healthcheck", timeout=10)
|
r = requests.get(base + "/api/v1/healthcheck", timeout=10)
|
||||||
if r.status_code != 200:
|
if r.status_code == 200:
|
||||||
return False, f"Grimmory not reachable (HTTP {r.status_code})"
|
|
||||||
# Verify credentials against Komga-compatible API
|
|
||||||
r2 = requests.get(base + "/komga/api/v1/books", params={"size": 1},
|
|
||||||
auth=(user, password), timeout=10)
|
|
||||||
if r2.status_code == 200:
|
|
||||||
return True, "Connected to Grimmory successfully"
|
return True, "Connected to Grimmory successfully"
|
||||||
if r2.status_code == 401:
|
return False, f"Grimmory not reachable (HTTP {r.status_code})"
|
||||||
return False, "Grimmory reachable but credentials rejected — check username and password"
|
|
||||||
return True, f"Grimmory reachable (API returned HTTP {r2.status_code})"
|
|
||||||
except requests.exceptions.ConnectionError:
|
except requests.exceptions.ConnectionError:
|
||||||
return False, "Could not connect — check the URL"
|
return False, "Could not connect — check the URL"
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
+14
-4
@@ -225,10 +225,15 @@
|
|||||||
class="textarea textarea-bordered w-full font-mono text-xs"
|
class="textarea textarea-bordered w-full font-mono text-xs"
|
||||||
placeholder="Paste new key to replace. Leave empty to keep current."></textarea>
|
placeholder="Paste new key to replace. Leave empty to keep current."></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div x-show="authMethod === 'password'">
|
<div x-show="authMethod === 'password'" x-data="{ show: false }">
|
||||||
<label class="label py-1"><span class="label-text text-xs">SSH password</span></label>
|
<label class="label py-1"><span class="label-text text-xs">SSH password</span></label>
|
||||||
<input name="sftp_password" type="password" class="input input-bordered input-sm w-full"
|
<div class="join w-full">
|
||||||
|
<input name="sftp_password" :type="show ? 'text' : 'password'"
|
||||||
|
class="input input-bordered input-sm join-item flex-1"
|
||||||
placeholder="Leave empty to keep current" />
|
placeholder="Leave empty to keep current" />
|
||||||
|
<button type="button" class="btn btn-sm btn-outline join-item"
|
||||||
|
@click="show = !show" x-text="show ? 'Hide' : 'Show'"></button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -263,10 +268,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
|
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
|
||||||
<div class="form-control">
|
<div class="form-control" x-data="{ show: false }">
|
||||||
<label class="label py-1"><span class="label-text text-xs">Password</span></label>
|
<label class="label py-1"><span class="label-text text-xs">Password</span></label>
|
||||||
<input name="grimmory_password" type="password" class="input input-bordered input-sm"
|
<div class="join w-full">
|
||||||
|
<input name="grimmory_password" :type="show ? 'text' : 'password'"
|
||||||
|
class="input input-bordered input-sm join-item flex-1"
|
||||||
placeholder="Leave empty to keep current" />
|
placeholder="Leave empty to keep current" />
|
||||||
|
<button type="button" class="btn btn-sm btn-outline join-item"
|
||||||
|
@click="show = !show" x-text="show ? 'Hide' : 'Show'"></button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-control">
|
<div class="form-control">
|
||||||
<label class="label py-1">
|
<label class="label py-1">
|
||||||
|
|||||||
Reference in New Issue
Block a user