[#1349] Basic Cookie Authentication (#1498)

* [#1349] Stub basic cookie authentication

* [#1349] Basic login page

Also adjusts WebView header color and shadow to match WebUI. WebUI uses
a background-image gradient to change the perceived color, which was not
noticed originally.

* [#1349] Handle login post

* [#1349] Redirect to previous URL

* [#1349] Return a basic 401 for api endpoints

Instead of redirecting to a visual login page, API should just indicate
the bad state

* Use more appropriate 303 redirect

* Update server/src/main/kotlin/suwayomi/tachidesk/server/JavalinSetup.kt

Co-authored-by: Mitchell Syer <Syer10@users.noreply.github.com>

* Update server/src/main/kotlin/suwayomi/tachidesk/server/JavalinSetup.kt

Co-authored-by: Mitchell Syer <Syer10@users.noreply.github.com>

* Lint

* Transition to AuthMode enum with migration path

* Make basicAuthEnabled auto property, Lint

* ConfigManager: Make sure to re-parse the config after migration

* basicAuth{Username,Password} -> auth{Username,Password}

* Lint

* Update server settings backup model

* Update comment

* Minor cleanup

* Improve backup legacy settings fix

* Lint

* Simplify config value migration

---------

Co-authored-by: Mitchell Syer <Syer10@users.noreply.github.com>
This commit is contained in:
Constantin Piber
2025-07-06 18:08:29 +02:00
committed by GitHub
parent 1411c02e18
commit 68a131dbeb
15 changed files with 432 additions and 34 deletions

View File

@@ -43,9 +43,9 @@ server.globalUpdateInterval = 12 # time in hours - 0 to disable it - (doesn't ha
server.updateMangas = false # if the mangas should be updated along with the chapter list during a library/category update
# Authentication
server.basicAuthEnabled = false
server.basicAuthUsername = ""
server.basicAuthPassword = ""
server.authMode = "none" # none, basic_auth or simple_login
server.authUsername = ""
server.authPassword = ""
# misc
server.debugLogsEnabled = false

View File

@@ -0,0 +1,164 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Suwayomi Login</title>
<style>
* {
box-sizing: border-box;
}
html, body {
margin: 0;
padding: 0;
height: 100%;
}
body {
display: flex;
flex-direction: column;
background-color: rgb(12, 16, 33);
font-family: "Roboto","Helvetica","Arial",sans-serif;
font-weight: 400;
letter-spacing: 0em;
}
button[disabled], input[disabled] {
cursor: not-allowed;
}
header {
background-color: rgb(34, 38, 53);
box-shadow: rgba(0, 0, 0, 0.2) 0px 2px 4px -1px, rgba(0, 0, 0, 0.14) 0px 4px 5px 0px, rgba(0, 0, 0, 0.12) 0px 1px 10px 0px;
color: #fff;
padding: 8px 32px;
}
header h1, header p {
margin: 0;
}
footer {
color: #fff;
padding: 8px;
}
footer p {
margin: 0;
font-size: 0.7rem;
}
main {
height: 100%;
}
main {
position: relative;
padding-top: 24px;
}
form {
margin: 8px;
padding: 8px 24px;
border-radius: 8px;
border: 1px solid rgb(12, 16, 33);
background-color: rgb(6, 8, 16);
color: white;
}
.error {
margin: 8px;
padding: 8px 16px;
border-radius: 8px;
border: 1px solid #b71c1c;
background-color: #c62828;
color: white;
}
.error:empty {
display: none;
}
form label {
cursor: pointer;
}
form button {
all: unset;
padding: 8px;
line-height: 1.75;
text-align: center;
min-width: 64px;
border-radius: 4px;
padding: 6px 8px;
color: rgb(91, 116, 239);
text-transform: uppercase;
letter-spacing: 0.02857em;
}
form button:not([disabled]) {
cursor: pointer;
}
form button:not([disabled]):hover {
background-color: rgba(91, 116, 239, 0.08);
}
form input {
all: unset;
border-radius: 4px;
border: 1px solid rgba(255, 255, 255, 0.23);
padding: 6px 12px;
width: auto;
min-width: 0;
}
form input:hover {
border-color: white;
}
form input:focus {
border-color: rgb(91, 116, 239);
}
form .controls {
display: grid;
align-items: center;
grid-template-columns: 1fr;
}
form .controls > :nth-child(even):not(:last-child) {
margin-bottom: 6px;
}
form .submit {
display: flex;
flex-direction: column;
align-items: center;
margin-top: 24px;
}
@media (min-width: 500px) {
form {
width: 100%;
max-width: 450px;
margin: 8px auto;
}
.error {
width: 100%;
max-width: 450px;
margin: 8px auto;
}
form .controls {
grid-template-columns: auto 1fr;
column-gap: 16px;
row-gap: 6px;
}
form .controls > :nth-child(even):not(:last-child) {
margin-bottom: 0px;
}
}
</style>
</head>
<body>
<header>
<h1>Suwayomi</h1>
</header>
<main>
<div class="error">[ERROR]</div>
<form method="POST">
<h2>Login</h2>
<div class="controls">
<label for="user">Username:</label>
<input type="text" name="user" id="user" required placeholder="Type username..."/>
<label for="pass">Password:</label>
<input type="password" name="pass" id="pass" required placeholder="Secret..."/>
</div>
<div class="submit">
<button type="submit">Log In</button>
</div>
</form>
</main>
<footer>
<p>Suwayomi: Version [VERSION]</p>
</footer>
</body>
</html>

View File

@@ -15,6 +15,9 @@
body {
display: flex;
flex-direction: column;
font-family: "Roboto","Helvetica","Arial",sans-serif;
font-weight: 400;
letter-spacing: 0em;
}
body.disconnected::after {
content: 'Disconnected, please refresh';
@@ -30,7 +33,8 @@
cursor: not-allowed;
}
header {
background-color: rgb(12, 16, 33);
background-color: rgb(34, 38, 53);
box-shadow: rgba(0, 0, 0, 0.2) 0px 2px 4px -1px, rgba(0, 0, 0, 0.14) 0px 4px 5px 0px, rgba(0, 0, 0, 0.12) 0px 1px 10px 0px;
color: #fff;
padding: 8px 32px;
}