#176 fix slug links with password protection

This commit is contained in:
Alan Grainger
2026-01-26 21:01:58 +13:00
parent 8a5df29bcd
commit ecf98bf7f8
4 changed files with 14 additions and 17 deletions
+1 -1
View File
@@ -154,7 +154,7 @@ Alternatively, you can [pass the configuration inline](docs/inline-configuration
| `responseHeaders` | `object` | Change the headers sent with your web responses. By default there is `cache-control` and CORS added. | | `responseHeaders` | `object` | Change the headers sent with your web responses. By default there is `cache-control` and CORS added. |
| `singleImageGallery` | `bool` | By default a link to a single image will directly open the image file. Set to `true` if you want to show a gallery page instead for a single item. | | `singleImageGallery` | `bool` | By default a link to a single image will directly open the image file. Set to `true` if you want to show a gallery page instead for a single item. |
| `downloadOriginalPhoto` | `bool` | Set to `false` if you only want people to be able to download the 'preview' quality photo, rather than your original photo. | | `downloadOriginalPhoto` | `bool` | Set to `false` if you only want people to be able to download the 'preview' quality photo, rather than your original photo. |
| `downloadedFilename` | `int` | The filename of the downloaded image.<br>`0` for the original filename if available, falling back to the Immich asset ID<br>`1` for the Immich asset ID number<br>`2` for a sanitised version of the asset ID: `img_` plus the first 8 characters of the asset ID | | `downloadedFilename` | `int` | The filename of the downloaded image.<br>`0` for the original filename if available, falling back to the Immich asset ID<br>`1` for the Immich asset ID number<br>`2` for a shortened version of the asset ID: `img_` plus the first 8 characters of the asset ID |
| `showGalleryTitle` | `bool` | Show a title on the gallery page. | | `showGalleryTitle` | `bool` | Show a title on the gallery page. |
| `allowDownloadAll` | `int` | Allow visitors to download all files as a zip.<br>`0` disable downloads<br>`1` follow Immich setting per share ([example](https://github.com/user-attachments/assets/79ea8c08-71ce-42ab-b025-10aec384938a))<br>`2` always allowed | | `allowDownloadAll` | `int` | Allow visitors to download all files as a zip.<br>`0` disable downloads<br>`1` follow Immich setting per share ([example](https://github.com/user-attachments/assets/79ea8c08-71ce-42ab-b025-10aec384938a))<br>`2` always allowed |
| `allowSlugLinks` | `bool` | Enable/disable the custom URL links. | | `allowSlugLinks` | `bool` | Enable/disable the custom URL links. |
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "immich-public-proxy", "name": "immich-public-proxy",
"version": "1.15.0", "version": "1.15.1",
"scripts": { "scripts": {
"dev": "ts-node src/index.ts", "dev": "ts-node src/index.ts",
"build": "npx tsc", "build": "npx tsc",
+8 -7
View File
@@ -14,6 +14,7 @@ import { addResponseHeaders, canDownload, getConfigOption, log } from './functio
import render from './render' import render from './render'
import { Response } from 'express-serve-static-core' import { Response } from 'express-serve-static-core'
import { respondToInvalidRequest } from './invalidRequestHandler' import { respondToInvalidRequest } from './invalidRequestHandler'
import { encrypt } from './encrypt'
class Immich { class Immich {
/** /**
@@ -104,13 +105,13 @@ class Immich {
} }
const link = sharedLinkRes.link const link = sharedLinkRes.link
// Make sure there are some photo/video assets for this link // If this was a slug link, we need to also store session information for the ID-based key
/* if (request.req.session && !request.req.session[link.key]) {
if (!link.assets.length) { request.req.session[link.key] = encrypt(JSON.stringify({
log('No assets for key ' + request.key) password: request.password,
respondToInvalidRequest(res, 404) expires: dayjs().add(1, 'hour').format()
return }))
} */ }
// Everything is ok - output the shared link data // Everything is ok - output the shared link data
+4 -8
View File
@@ -95,6 +95,10 @@ app.get('/:shareType(share|s)/:key/:mode(download)?', decodeCookie, async (req,
* [ROUTE] Receive an unlock request from the password page * [ROUTE] Receive an unlock request from the password page
* Stores a cookie with an encrypted payload which expires in 1 hour. * Stores a cookie with an encrypted payload which expires in 1 hour.
* After that time, the visitor will need to provide the password again. * After that time, the visitor will need to provide the password again.
*
* The data is encrypted/decrypted on the server as a db-less way of
* managing user session data. The data is provided to the server by the
* user's browser in its encrypted state.
*/ */
app.post('/share/unlock', async (req, res) => { app.post('/share/unlock', async (req, res) => {
if (req.session && req.body.key) { if (req.session && req.body.key) {
@@ -125,13 +129,6 @@ app.get('/share/:type(photo|video)/:key/:id/:size?', decodeCookie, async (req, r
return return
} }
/*
This was the change made in PR https://github.com/alangrainger/immich-public-proxy/pull/174
I have had to remove this because it was preventing password-protected slug albums
from working.
This will be added back in once the slug issue is solved.
// Validate share link and check password before serving assets // Validate share link and check password before serving assets
// This prevents direct URL access from bypassing password protection // This prevents direct URL access from bypassing password protection
// The password is provided from the encrypted session cookie (if set) // The password is provided from the encrypted session cookie (if set)
@@ -153,7 +150,6 @@ app.get('/share/:type(photo|video)/:key/:id/:size?', decodeCookie, async (req, r
respondToInvalidRequest(res, 404, 'Asset not found in share') respondToInvalidRequest(res, 404, 'Asset not found in share')
return return
} }
*/
const request = { const request = {
req, req,