You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.MD
+17Lines changed: 17 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,23 @@ All notable changes to this project will be documented in this file.
4
4
5
5
**Warning:** Features marked as *alpha* may change or be removed in a future release without notice. Use with caution.
6
6
7
+
## [0.6.0] - 2025-11-03
8
+
9
+
### Added
10
+
11
+
- When using the serve command, a new `-m` flag allows for authenticated access to publications using a JWT in the route to the publication instead of the encoded path. The subject (`sub`) of the JWT will instead be used as the path to the publication. The first new mode is `jwt` mode, which uses the HS256 method of authentication and a shared secret that is either provided using `--jwt-shared-secret` or autogenerated at startup. The second mode, `jwks`, is combined with the `--jwks-url` flag that points to JWKS file, which can contain multiple keys used to validate the JWT, allowing for key rotation and other algorithms using public/private keypairs
12
+
- The path of a publication with no resource specified now redirects to the manifest file
13
+
14
+
### Changed
15
+
16
+
- The GOAMD64 value for release builds has been changed from `v3` to `v2`. The discussion regarding this is [here](https://github.com/readium/cli/issues/78). This allows execution of the built binaries on older x64 CPUs
17
+
- The HTTP client configuration used for streaming of remote publications has been changed to require, at minimum, TLSv1.2 for HTTPS connections
18
+
- The serve command's routes are now prefixed with `/webpub`. So `<domain>/<path>/manifest.json` is now `<domain>/webpub/<path>/manifest.json`
19
+
20
+
### Removed
21
+
22
+
- The `/list.json` route in the serve command's webserver has been removed. It is not compatible with the new authenticated access schemes, and was only intended to be temporary. It may be replaced in the future by an OPDS2 feed
Copy file name to clipboardExpand all lines: internal/cli/serve.go
+60-11Lines changed: 60 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,8 @@ package cli
2
2
3
3
import (
4
4
"context"
5
+
"crypto/rand"
6
+
"encoding/hex"
5
7
"fmt"
6
8
"log"
7
9
"net/http"
@@ -22,6 +24,7 @@ import (
22
24
"github.com/aws/aws-sdk-go-v2/service/s3"
23
25
"github.com/pkg/errors"
24
26
"github.com/readium/cli/pkg/serve"
27
+
"github.com/readium/cli/pkg/serve/auth"
25
28
"github.com/readium/cli/pkg/serve/client"
26
29
"github.com/readium/go-toolkit/pkg/streamer"
27
30
"github.com/readium/go-toolkit/pkg/util/url"
@@ -39,6 +42,11 @@ var schemeFlag []string
39
42
40
43
varfileDirectoryFlagstring
41
44
45
+
varmodestring
46
+
47
+
varjwtSharedSecretstring
48
+
varjwksURLstring
49
+
42
50
// Cloud-related flags
43
51
vars3EndpointFlagstring
44
52
vars3RegionFlagstring
@@ -57,24 +65,20 @@ var remoteArchiveCacheAll uint32
57
65
58
66
varserveCmd=&cobra.Command{
59
67
Use: "serve",
60
-
Short: "Start a local HTTP server, serving a specified directory of publications",
61
-
Long: `Start a local HTTP server, serving a specified directory of publications.
68
+
Short: "Start a local HTTP server, serving publications locally or remotely",
69
+
Long: `Start a local HTTP server, serving publications locally or remotely.
62
70
63
-
This command will start an HTTP serve listening by default on 'localhost:15080',
71
+
This command will start an HTTP server listening by default on 'localhost:15080',
64
72
serving all compatible files (EPUB, PDF, CBZ, etc.) available from the enabled
65
73
access schemes (file, http, https, s3, gs, or a local path if file scheme is enabled)
66
74
as Readium Web Publications. To get started, the manifest can be accessed from
67
75
'http://localhost:15080/<filename in base64url encoding without padding>/manifest.json'.
68
76
This file serves as the entry point and contains metadata and links to the rest
69
77
of the files that can be accessed for the publication.
70
78
71
-
If local file access is enabled, the server also exposes a '/list.json' endpoint that,
72
-
for debugging purposes, returns a list of all the publications found in the directory
73
-
along with their encoded paths. This will be replaced by an OPDS 2 feed (or similar)
74
-
in a future release.
75
-
76
-
Note: Take caution before exposing this server on the internet. It does not
77
-
implement any authentication, and may have more access to files than expected.`,
79
+
Authentication can be enabled using the -m flag, which replaces the encoded path
80
+
with a JWT. Before exposing this server publicly, consider using this flag to secure
81
+
access to publications and prevent abuse or unauthorized access.`,
serveCmd.Flags().StringVarP(&mode, "mode", "m", "base64", "Access mode: base64 (default, base64url-encoded paths), jwt (JWT auth with a shared secret), jwks (JWT auth with keys in a JWKS)")
297
+
298
+
serveCmd.Flags().StringVar(&jwtSharedSecret, "jwt-shared-secret", "", "Hex-encoded shared secret used for HS256 JWT signature validation. If omitted, but JWT auth is enabled, the secret is auto-generated and logged (debug) at runtime")
299
+
serveCmd.Flags().StringVar(&jwksURL, "jwks-url", "", "URL to a JWKS (JSON Web Key Set) used for JWT signature validation when in 'jwks' mode")
251
300
252
301
serveCmd.Flags().StringVar(&fileDirectoryFlag, "file-directory", "", "Local directory path to serve publications from")
0 commit comments