diff --git a/backend/_docker/Dockerfile b/backend/_docker/Dockerfile new file mode 100644 index 0000000000..be57b8dc36 --- /dev/null +++ b/backend/_docker/Dockerfile @@ -0,0 +1,49 @@ +FROM gtstef/ffmpeg:8.0-decode AS ffmpeg +FROM golang:alpine AS base +ARG VERSION +ARG REVISION +WORKDIR /app +COPY ./backend ./ +RUN apk update && apk add --no-cache gcc musl-dev upx +ENV CGO_ENABLED=1 +ENV GOEXPERIMENT=greenteagc +RUN go build -tags mupdf,musl -ldflags="-w -s \ + -X 'github.com/gtsteffaniak/filebrowser/backend/common/version.Version=${VERSION}' \ + -X 'github.com/gtsteffaniak/filebrowser/backend/common/version.CommitSHA=${REVISION}'" \ + -o filebrowser . +RUN upx filebrowser + +FROM node:lts-slim AS nbuild +WORKDIR /app +COPY ./frontend/package.json ./ +RUN apt-get update && apt-get install -y --no-install-recommends git ca-certificates \ + && git config --global url."https://github.com/".insteadOf "git@github.com:" \ + && git config --global url."https://github.com/".insteadOf "ssh://git@github.com/" +RUN npm i --maxsockets 1 +COPY ./frontend/ ./ +RUN npm run build:docker + +FROM alpine:latest +COPY --from=ffmpeg [ "/ffmpeg", "/ffprobe", "/usr/local/bin/" ] +ENV FILEBROWSER_FFMPEG_PATH="/usr/local/bin/" +ENV FILEBROWSER_DATABASE="/home/filebrowser/data/database.db" +ENV PATH="$PATH:/home/filebrowser" +RUN apk --no-cache add ca-certificates mailcap tzdata curl +RUN adduser -D -s /bin/true -u 1000 filebrowser +USER filebrowser +WORKDIR /home/filebrowser +# copy config to two locations for compatibility +COPY --from=base --chown=filebrowser:1000 [ "/app/filebrowser", "/app/config.yaml", "./" ] +COPY --from=base --chown=filebrowser:1000 [ "/app/config.yaml", "./data/config.yaml" ] +COPY --from=base --chown=filebrowser:1000 [ "/app/reduce-rounded-corners.css", "./" ] +COPY --from=nbuild --chown=filebrowser:1000 [ "/app/dist/", "./http/dist/" ] +## sanity checks +RUN [ "filebrowser", "version" ] +RUN [ "ffmpeg", "-version" ] +RUN [ "ffprobe", "-version" ] +USER root +# exposing default port for auto discovery. +EXPOSE 80 +HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \ + CMD curl -f http://localhost:80/health || exit 1 +ENTRYPOINT [ "./filebrowser" ] diff --git a/backend/_docker/Dockerfile.playwright-base b/backend/_docker/Dockerfile.playwright-base new file mode 100644 index 0000000000..77c5f46296 --- /dev/null +++ b/backend/_docker/Dockerfile.playwright-base @@ -0,0 +1,4 @@ +FROM node:22-slim +WORKDIR /app/frontend +RUN npm i @playwright/test oauth2-mock-server @types/node +RUN npx playwright install --with-deps firefox diff --git a/backend/_docker/Dockerfile.playwright-general b/backend/_docker/Dockerfile.playwright-general new file mode 100644 index 0000000000..6bd418400d --- /dev/null +++ b/backend/_docker/Dockerfile.playwright-general @@ -0,0 +1,19 @@ +FROM ghcr.io/gtsteffaniak/playwright-base:latest +WORKDIR /app + +# Copy setup scripts first to leverage caching +COPY [ "./_docker/src/general/", "./" ] + +WORKDIR /app/frontend +COPY [ "./_docker/src/general/frontend/", "./" ] +COPY [ "./frontend/tests/", "./tests" ] + +WORKDIR /app/backend/ +COPY [ "./backend/filebrowser*", "./"] +COPY [ "./backend/reduce-rounded-corners.css", "./no-rounded.css" ] +RUN mkdir -p ./http/dist +COPY [ "./backend/http/embed/", "./http/dist/"] + +# Run tests +RUN ./filebrowser set -u testuser1,testuser1 +RUN ./filebrowser & sleep 2 && cd ../frontend && npx playwright test diff --git a/backend/_docker/Dockerfile.playwright-no-config b/backend/_docker/Dockerfile.playwright-no-config new file mode 100644 index 0000000000..00b5a2e02b --- /dev/null +++ b/backend/_docker/Dockerfile.playwright-no-config @@ -0,0 +1,17 @@ +FROM ghcr.io/gtsteffaniak/playwright-base:latest +WORKDIR /app + +# Copy setup scripts first to leverage caching +COPY [ "./_docker/src/no-config/", "./" ] + +WORKDIR /app/frontend +COPY [ "./_docker/src/no-config/frontend/", "./" ] +COPY [ "./frontend/tests/", "./tests" ] + +WORKDIR /app/backend/ +COPY [ "./backend/filebrowser*", "./"] +RUN mkdir -p ./http/dist +COPY [ "./backend/http/embed/", "./http/dist/"] + +# Run tests +RUN ./filebrowser & sleep 2 && cd ../frontend && npx playwright test diff --git a/backend/_docker/Dockerfile.playwright-noauth b/backend/_docker/Dockerfile.playwright-noauth new file mode 100644 index 0000000000..87c44d3a9f --- /dev/null +++ b/backend/_docker/Dockerfile.playwright-noauth @@ -0,0 +1,17 @@ +FROM ghcr.io/gtsteffaniak/playwright-base:latest +WORKDIR /app + +# Copy setup scripts first to leverage caching +COPY [ "./_docker/src/noauth/", "./" ] + +WORKDIR /app/frontend +COPY [ "./frontend/tests", "./tests" ] +COPY [ "./frontend/tests/playwright-files", "./tests/playwright-files2" ] + +WORKDIR /app/backend/ +COPY [ "./backend/filebrowser", "./"] +RUN mkdir -p ./http/dist +COPY [ "./backend/http/embed/", "./http/dist/"] + +# Run tests +#RUN ./filebrowser & sleep 2 && cd ../frontend && npx playwright test \ No newline at end of file diff --git a/backend/_docker/Dockerfile.playwright-oidc b/backend/_docker/Dockerfile.playwright-oidc new file mode 100644 index 0000000000..166e6c1e80 --- /dev/null +++ b/backend/_docker/Dockerfile.playwright-oidc @@ -0,0 +1,13 @@ +FROM ghcr.io/gtsteffaniak/playwright-base:latest + +COPY [ "./_docker/src/oidc/frontend/", "./" ] +COPY [ "./frontend/tests/", "./tests" ] + +WORKDIR /app/backend/ +RUN mkdir -p ./http/dist +COPY [ "./_docker/src/oidc/backend/", "./"] +COPY ["./backend/filebrowser", "./"] +COPY [ "./backend/http/embed/", "./http/dist/"] +# Run tests +WORKDIR /app/frontend +RUN node mock-oidc-server.js & sleep 2 && cd ../backend/ && ./filebrowser & sleep 2 && cd ../frontend && npx playwright test diff --git a/backend/_docker/Dockerfile.playwright-proxy b/backend/_docker/Dockerfile.playwright-proxy new file mode 100644 index 0000000000..e9facb66be --- /dev/null +++ b/backend/_docker/Dockerfile.playwright-proxy @@ -0,0 +1,14 @@ +FROM ghcr.io/gtsteffaniak/playwright-base:latest +WORKDIR /app +COPY [ "./_docker/src/proxy/", "./" ] +WORKDIR /app/frontend +COPY [ "./frontend/tests", "./tests" ] +WORKDIR /app/backend/ +COPY [ "./backend/filebrowser", "./"] +RUN mkdir -p ./http/dist +COPY [ "./backend/http/embed/", "./http/dist/"] +RUN apt update && apt install nginx -y +RUN mv default.conf /etc/nginx/conf.d/default.conf +RUN mv .htpasswd /etc/nginx/conf.d/.htpasswd +RUN sed -i 's/filebrowser/localhost/g' /etc/nginx/conf.d/default.conf +RUN nginx & ./filebrowser & sleep 2 && cd ../frontend && npx playwright test diff --git a/backend/_docker/Dockerfile.playwright-settings b/backend/_docker/Dockerfile.playwright-settings new file mode 100644 index 0000000000..00b5a2e02b --- /dev/null +++ b/backend/_docker/Dockerfile.playwright-settings @@ -0,0 +1,17 @@ +FROM ghcr.io/gtsteffaniak/playwright-base:latest +WORKDIR /app + +# Copy setup scripts first to leverage caching +COPY [ "./_docker/src/no-config/", "./" ] + +WORKDIR /app/frontend +COPY [ "./_docker/src/no-config/frontend/", "./" ] +COPY [ "./frontend/tests/", "./tests" ] + +WORKDIR /app/backend/ +COPY [ "./backend/filebrowser*", "./"] +RUN mkdir -p ./http/dist +COPY [ "./backend/http/embed/", "./http/dist/"] + +# Run tests +RUN ./filebrowser & sleep 2 && cd ../frontend && npx playwright test diff --git a/backend/_docker/Dockerfile.playwright-sharing b/backend/_docker/Dockerfile.playwright-sharing new file mode 100644 index 0000000000..19ce17fb92 --- /dev/null +++ b/backend/_docker/Dockerfile.playwright-sharing @@ -0,0 +1,17 @@ +FROM ghcr.io/gtsteffaniak/playwright-base:latest +WORKDIR /app + +# Copy setup scripts first to leverage caching +COPY [ "./_docker/src/sharing/", "./" ] + +WORKDIR /app/frontend +COPY [ "./_docker/src/sharing/frontend/", "./" ] +COPY [ "./frontend/tests/", "./tests" ] + +WORKDIR /app/backend/ +COPY [ "./backend/filebrowser*", "./"] +RUN mkdir -p ./http/dist +COPY [ "./backend/http/embed/", "./http/dist/"] + +# Run tests +RUN ./filebrowser & sleep 2 && cd ../frontend && npx playwright test diff --git a/backend/_docker/Dockerfile.primecache b/backend/_docker/Dockerfile.primecache new file mode 100644 index 0000000000..21f9712eb2 --- /dev/null +++ b/backend/_docker/Dockerfile.primecache @@ -0,0 +1 @@ +FROM ghcr.io/gtsteffaniak/playwright-base:latest \ No newline at end of file diff --git a/backend/_docker/Dockerfile.slim b/backend/_docker/Dockerfile.slim new file mode 100644 index 0000000000..15c29af78f --- /dev/null +++ b/backend/_docker/Dockerfile.slim @@ -0,0 +1,42 @@ +FROM golang:alpine AS base +ARG VERSION +ARG REVISION +WORKDIR /app +COPY ./backend ./ +RUN apk update && apk add upx +ENV GOEXPERIMENT=greenteagc +RUN go build -ldflags="-w -s \ + -X 'github.com/gtsteffaniak/filebrowser/backend/common/version.Version=${VERSION}' \ + -X 'github.com/gtsteffaniak/filebrowser/backend/common/version.CommitSHA=${REVISION}'" \ + -o filebrowser . +RUN upx filebrowser + +FROM node:lts-slim AS nbuild +WORKDIR /app +COPY ./frontend/package.json ./ +RUN apt-get update && apt-get install -y --no-install-recommends git ca-certificates \ + && git config --global url."https://github.com/".insteadOf "git@github.com:" \ + && git config --global url."https://github.com/".insteadOf "ssh://git@github.com/" +RUN npm i --maxsockets 1 +COPY ./frontend/ ./ +RUN npm run build:docker + +FROM alpine:latest +ENV FILEBROWSER_DATABASE="/home/filebrowser/data/database.db" +ENV PATH="$PATH:/home/filebrowser" +RUN apk --no-cache add ca-certificates mailcap tzdata curl +RUN adduser -D -s /bin/true -u 1000 filebrowser +USER filebrowser +WORKDIR /home/filebrowser +COPY --from=base --chown=filebrowser:1000 [ "/app/filebrowser", "./" ] +COPY --from=base --chown=filebrowser:1000 [ "/app/config.yaml", "./data/config.yaml" ] +COPY --from=base --chown=filebrowser:1000 [ "/app/reduce-rounded-corners.css", "./" ] +COPY --from=nbuild --chown=filebrowser:1000 [ "/app/dist/", "./http/dist/" ] +## sanity checks +RUN [ "filebrowser", "version" ] +USER root +# exposing default port for auto discovery. +EXPOSE 80 +HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \ + CMD curl -f http://localhost:80/health || exit 1 +ENTRYPOINT [ "./filebrowser" ] diff --git a/backend/_docker/docker-compose.yaml b/backend/_docker/docker-compose.yaml new file mode 100644 index 0000000000..69c3e2907e --- /dev/null +++ b/backend/_docker/docker-compose.yaml @@ -0,0 +1,17 @@ +services: + nginx-proxy-auth: + image: nginx + container_name: nginx-proxy-auth + ports: + - "80:80" + volumes: + - ./src/proxy/backend/default.conf:/etc/nginx/conf.d/default.conf + - ./src/proxy/backend/.htpasswd:/etc/nginx/conf.d/.htpasswd + filebrowser: + hostname: filebrowser + volumes: + - '../frontend:/home/frontend' + - "./src/proxy/backend/config.yaml:/home/filebrowser/config.yaml" + build: + context: ../ + dockerfile: ./_docker/Dockerfile.slim diff --git a/backend/_docker/src/general/backend/config.yaml b/backend/_docker/src/general/backend/config.yaml new file mode 100644 index 0000000000..619223df45 --- /dev/null +++ b/backend/_docker/src/general/backend/config.yaml @@ -0,0 +1,15 @@ +server: + <<: *server-main +frontend: + <<: *frontend-main + +userDefaults: + preview: + image: true + popup: true + video: true + office: true + highQuality: true + permissions: + download: true + create: true \ No newline at end of file diff --git a/backend/_docker/src/general/backend/frontend-config.yaml b/backend/_docker/src/general/backend/frontend-config.yaml new file mode 100644 index 0000000000..accea88553 --- /dev/null +++ b/backend/_docker/src/general/backend/frontend-config.yaml @@ -0,0 +1,12 @@ +frontend-main: &frontend-main + name: "Graham's Filebrowser" + disableDefaultLinks: true + styling: + customThemes: + no-rounded: + description: "No rounded corners" # The description of the theme to display in the UI. + css: "no-rounded.css" # The css file path and filename to use for the theme. + externalLinks: + - text: "A playwright test" + url: "https://playwright.dev/" + title: "Playwright" \ No newline at end of file diff --git a/backend/_docker/src/general/backend/server-config.yaml b/backend/_docker/src/general/backend/server-config.yaml new file mode 100644 index 0000000000..283650f6b1 --- /dev/null +++ b/backend/_docker/src/general/backend/server-config.yaml @@ -0,0 +1,15 @@ +server-main: &server-main + port: 80 + baseURL: "/" + logging: + - levels: "info|error|debug" + sources: + - path: "../frontend/tests/playwright-files" + name: "playwright + files" + config: + defaultEnabled: true + - path: "." + name: "docker" + config: + disableIndexing: true + defaultEnabled: true \ No newline at end of file diff --git a/backend/_docker/src/general/frontend/playwright.config.ts b/backend/_docker/src/general/frontend/playwright.config.ts new file mode 100644 index 0000000000..ec7ccd3dd6 --- /dev/null +++ b/backend/_docker/src/general/frontend/playwright.config.ts @@ -0,0 +1,47 @@ +import { defineConfig, devices } from "@playwright/test"; + +/** + * Read environment variables from file. + * https://github.com/motdotla/dotenv + */ +// require('dotenv').config(); + +/** + * See https://playwright.dev/docs/test-configuration. + */ +export default defineConfig({ + globalSetup: "./tests/playwright/global-setup", + timeout: 10000, + testDir: "./tests/playwright/general", + /* Run tests in files in parallel */ + fullyParallel: false, + /* Fail the build on CI if you accidentally left test.only in the source code. */ + forbidOnly: false, + /* Retry on CI only */ + retries: 2, + /* Opt out of parallel tests on CI. */ + workers: 1, + /* Reporter to use. See https://playwright.dev/docs/test-reporters */ + reporter: "line", + /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ + use: { + actionTimeout: 5000, + storageState: "loginAuth.json", + /* Base URL to use in actions like `await page.goto('/')`. */ + baseURL: "http://127.0.0.1/", + + /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ + trace: "on-first-retry", + + /* Set default locale to English (US) */ + locale: "en-US", + }, + + /* Configure projects for major browsers */ + projects: [ + { + name: "firefox", + use: { ...devices["Desktop Firefox"] }, + }, + ], +}); diff --git a/backend/_docker/src/no-config/frontend/playwright.config.ts b/backend/_docker/src/no-config/frontend/playwright.config.ts new file mode 100644 index 0000000000..500d1be008 --- /dev/null +++ b/backend/_docker/src/no-config/frontend/playwright.config.ts @@ -0,0 +1,47 @@ +import { defineConfig, devices } from "@playwright/test"; + +/** + * Read environment variables from file. + * https://github.com/motdotla/dotenv + */ +// require('dotenv').config(); + +/** + * See https://playwright.dev/docs/test-configuration. + */ +export default defineConfig({ + globalSetup: "./tests/playwright/no-config-setup", + timeout: 5000, + testDir: "./tests/playwright/no-config", + /* Run tests in files in parallel */ + fullyParallel: false, + /* Fail the build on CI if you accidentally left test.only in the source code. */ + forbidOnly: false, + /* Retry on CI only */ + retries: 2, + /* Opt out of parallel tests on CI. */ + workers: 1, + /* Reporter to use. See https://playwright.dev/docs/test-reporters */ + reporter: "line", + /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ + use: { + actionTimeout: 5000, + storageState: "loginAuth.json", + /* Base URL to use in actions like `await page.goto('/')`. */ + baseURL: "http://127.0.0.1/", + + /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ + trace: "on-first-retry", + + /* Set default locale to English (US) */ + locale: "en-US", + }, + + /* Configure projects for major browsers */ + projects: [ + { + name: "firefox", + use: { ...devices["Desktop Firefox"] }, + }, + ], +}); diff --git a/backend/_docker/src/noauth/backend/config.yaml b/backend/_docker/src/noauth/backend/config.yaml new file mode 100644 index 0000000000..7014abc85d --- /dev/null +++ b/backend/_docker/src/noauth/backend/config.yaml @@ -0,0 +1,53 @@ +server: + port: 80 + baseURL: "/files/" + logging: + - levels: "info|error|debug" + sources: + - path: "../frontend/tests/playwright-files" + name: "exclude" + config: + defaultEnabled: true + conditionals: + rules: + - folderPath: "excluded" + - folderPath: "excludedButVisible" + viewable: true + - path: "../frontend/tests/playwright-files2" + name: "include" + config: + defaultEnabled: true + conditionals: + rules: + - includeRootItem: "myfolder" + - includeRootItem: "subfolderExclusions" + - filePath: "/subfolderExclusions/exclusionlist.sh" + - folderPath: "/subfolderExclusions/folderItem" + viewable: true + - fileStartsWith: "startsWith" + - folderEndsWith: "Folder" + +auth: + methods: + noauth: true +frontend: + name: "Graham's Filebrowser" + disableDefaultLinks: true + externalLinks: + - text: "A playwright test" + url: "https://playwright.dev/" + title: "Playwright" +userDefaults: + permissions: + realtime: true + +userDefaults: + preview: + image: true + popup: true + video: true + office: true + highQuality: true + permissions: + download: true + create: true \ No newline at end of file diff --git a/backend/_docker/src/noauth/frontend/playwright.config.ts b/backend/_docker/src/noauth/frontend/playwright.config.ts new file mode 100644 index 0000000000..81ed5598fd --- /dev/null +++ b/backend/_docker/src/noauth/frontend/playwright.config.ts @@ -0,0 +1,48 @@ +import { defineConfig, devices } from "@playwright/test"; + +/** + * Read environment variables from file. + * https://github.com/motdotla/dotenv + */ +// require('dotenv').config(); + +/** + * See https://playwright.dev/docs/test-configuration. + */ +export default defineConfig({ + globalSetup: "./tests/playwright/noauth-setup", + timeout: 10000, + testDir: "./tests/playwright/noauth", + /* Run tests in files in parallel */ + fullyParallel: false, + /* Fail the build on CI if you accidentally left test.only in the source code. */ + forbidOnly: false, + /* Retry on CI only */ + retries: 2, + /* Opt out of parallel tests on CI. */ + workers: 1, // required for now! todo parallel some tests + /* Reporter to use. See https://playwright.dev/docs/test-reporters */ + reporter: "line", + /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ + use: { + storageState: "noauth.json", + actionTimeout: 5000, + //storageState: "loginAuth.json", + /* Base URL to use in actions like `await page.goto('/')`. */ + baseURL: "http://127.0.0.1", + + /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ + trace: "on-first-retry", + + /* Set default locale to English (US) */ + locale: "en-US", + }, + + /* Configure projects for major browsers */ + projects: [ + { + name: "firefox", + use: { ...devices["Desktop Firefox"] }, + }, + ], +}); diff --git a/backend/_docker/src/oidc/backend/config.yaml b/backend/_docker/src/oidc/backend/config.yaml new file mode 100644 index 0000000000..a4e27e255e --- /dev/null +++ b/backend/_docker/src/oidc/backend/config.yaml @@ -0,0 +1,46 @@ +server: + logging: + - levels: "info|error|warning|debug" + sources: + - path: "../frontend/tests/playwright-files" + config: + defaultEnabled: true + createUserDir: true + +frontend: + name: "Graham's Filebrowser" + disableDefaultLinks: true + externalLinks: + - text: "A playwright test" + url: "https://playwright.dev/" + title: "Playwright" + +auth: + methods: + password: + enabled: false + oidc: + enabled: true + createUser: true + clientId: "vyBrzOmcrU3OokiWEZoObdGBscw0eYPNJauBtOJr" + clientSecret: "gIMKbkEcckUhlGrnE2Vxi8eZhEcfxQqfwFgM0ATzk4DciHGrW2YRtQfqcpRTsmzrxEETkKvZ8yeK3sfoXnUV1IQTzqK7wxw3lEMtmeXi5clj0h7nH1rVGFq2Q3HL8zUe" + issuerUrl: "http://localhost:8080" + adminGroup: "Admins" + +userDefaults: + preview: + image: true + popup: true + video: true + office: true + highQuality: true + darkMode: true + disableSettings: false + singleClick: false + permissions: + admin: false + modify: true + share: false + api: false + download: true + create: true \ No newline at end of file diff --git a/backend/_docker/src/oidc/frontend/mock-oidc-server.js b/backend/_docker/src/oidc/frontend/mock-oidc-server.js new file mode 100644 index 0000000000..7e01ccfeda --- /dev/null +++ b/backend/_docker/src/oidc/frontend/mock-oidc-server.js @@ -0,0 +1,60 @@ + +import { OAuth2Server } from 'oauth2-mock-server'; + +// This is a list of pre-defined users. You can add more users here. +// The filebrowser application will use this data when a user logs in. +const users = { + // Default user + johndoe: { + sub: 'johndoe', + preferred_username: 'johndoe', + email: 'johndoe@example.com', + groups: ['Admins', 'Users'], + }, + // Another example user + testuser: { + sub: 'testuser', + preferred_username: 'testuser', + email: 'testuser@example.com', + groups: ['Users'], + }, +}; + +const server = new OAuth2Server(); + +// Generate a new RSA key for the server. +await server.issuer.keys.generate('RS256'); + +/** + * This hook is called before the ID token is signed. + * We're using it to add claims to the ID token. + * This is the primary way the application will get user information. + */ +server.service.on('beforeIdTokenSigning', (token, req) => { + // By default, the mock server uses 'johndoe' as the subject. + const user = users[token.payload.sub] || users.johndoe; + console.log(`[ID Token] Customizing token for user: ${user.sub}`); + Object.assign(token.payload, user); +}); + + +/** + * This hook is called before the userinfo response is sent. + * We're using it to provide user claims when the application calls the /userinfo endpoint. + */ +server.service.on('beforeUserinfo', (userInfoResponse, req) => { + const user = users.johndoe; + console.log(`[UserInfo] Customizing userinfo for user: ${user.sub}`); + userInfoResponse.body = user; +}); + + +const port = 8080; +const host = '0.0.0.0'; // Bind to 0.0.0.0 to be accessible within Docker +await server.start(port, host); +console.log(`OAuth 2 Mock Server listening on http://${host}:${port}`); +console.log(`Issuer URL: ${server.issuer.url}`); +console.log('---'); +console.log('Pre-defined users:'); +console.log(JSON.stringify(users, null, 2)); +console.log('---'); \ No newline at end of file diff --git a/backend/_docker/src/oidc/frontend/playwright.config.ts b/backend/_docker/src/oidc/frontend/playwright.config.ts new file mode 100644 index 0000000000..0c41823780 --- /dev/null +++ b/backend/_docker/src/oidc/frontend/playwright.config.ts @@ -0,0 +1,48 @@ +import { defineConfig, devices } from "@playwright/test"; + +/** + * Read environment variables from file. + * https://github.com/motdotla/dotenv + */ +// require('dotenv').config(); + +/** + * See https://playwright.dev/docs/test-configuration. + */ +export default defineConfig({ + globalSetup: "./tests/playwright/oidc-setup", + timeout: 5000, + testDir: "./tests/playwright/oidc", + /* Run tests in files in parallel */ + fullyParallel: false, + /* Fail the build on CI if you accidentally left test.only in the source code. */ + forbidOnly: false, + /* Retry on CI only */ + retries: 2, + /* Opt out of parallel tests on CI. */ + workers: 1, // required for now! todo parallel some tests + /* Reporter to use. See https://playwright.dev/docs/test-reporters */ + reporter: "line", + /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ + use: { + storageState: "loginAuth.json", + actionTimeout: 5000, + //storageState: "loginAuth.json", + /* Base URL to use in actions like `await page.goto('/')`. */ + baseURL: "http://127.0.0.1", + + /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ + trace: "on-first-retry", + + /* Set default locale to English (US) */ + locale: "en-US", + }, + + /* Configure projects for major browsers */ + projects: [ + { + name: "firefox", + use: { ...devices["Desktop Firefox"] }, + }, + ], +}); diff --git a/backend/_docker/src/proxy/backend/.htpasswd b/backend/_docker/src/proxy/backend/.htpasswd new file mode 100644 index 0000000000..1a1a24a8e0 --- /dev/null +++ b/backend/_docker/src/proxy/backend/.htpasswd @@ -0,0 +1 @@ +demo-127.0.0.1:$apr1$j5FRA4Bc$RYdNFuM7YAAo9Qtie8w4b/ diff --git a/backend/_docker/src/proxy/backend/config.yaml b/backend/_docker/src/proxy/backend/config.yaml new file mode 100644 index 0000000000..a42083558e --- /dev/null +++ b/backend/_docker/src/proxy/backend/config.yaml @@ -0,0 +1,46 @@ +server: + port: 8080 + baseURL: "/subpath" + logging: + - levels: "info|error|debug" + sources: + - path: "../frontend/tests/playwright-files" + config: + defaultEnabled: true + createUserDir: true + +frontend: + name: "Graham's Filebrowser" + disableDefaultLinks: true + externalLinks: + - text: "A playwright test" + url: "https://playwright.dev/" + title: "Playwright" + +auth: + methods: + password: + enabled: false + proxy: + enabled: true + header: "X-Username" + createUser: true + logoutRedirectUrl: "https://localhost/api/auth/logout2" + +userDefaults: + preview: + image: true + popup: true + video: true + office: true + highQuality: true + darkMode: true + disableSettings: false + singleClick: false + permissions: + admin: false + modify: true + share: true + api: false + download: true + create: true \ No newline at end of file diff --git a/backend/_docker/src/proxy/backend/default.conf b/backend/_docker/src/proxy/backend/default.conf new file mode 100644 index 0000000000..6411f63d70 --- /dev/null +++ b/backend/_docker/src/proxy/backend/default.conf @@ -0,0 +1,32 @@ + +map $remote_addr $uuid { + default "demo-${remote_addr}"; +} + +server { + listen 80; + server_name localhost 127.0.0.1; + + location /subpath/public/ { + proxy_pass http://filebrowser:8080/subpath/public/; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Username $uuid; + } + + # requires basic auth demo-127.0.0.1:SecurePass123! + location /subpath { + auth_basic "Restricted Access"; + auth_basic_user_file /etc/nginx/conf.d/.htpasswd; + proxy_set_header X-Username $uuid; + add_header X-Username $uuid; + proxy_pass http://filebrowser:8080/subpath; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + +} diff --git a/backend/_docker/src/proxy/frontend/playwright.config.ts b/backend/_docker/src/proxy/frontend/playwright.config.ts new file mode 100644 index 0000000000..42379bcd49 --- /dev/null +++ b/backend/_docker/src/proxy/frontend/playwright.config.ts @@ -0,0 +1,47 @@ +import { defineConfig, devices } from "@playwright/test"; + +/** + * Read environment variables from file. + * https://github.com/motdotla/dotenv + */ +// require('dotenv').config(); + +/** + * See https://playwright.dev/docs/test-configuration. + */ +export default defineConfig({ + globalSetup: "./tests/playwright/proxy-setup.ts", + timeout: 5000, + testDir: "./tests/playwright/proxy", + /* Run tests in files in parallel */ + fullyParallel: false, + /* Fail the build on CI if you accidentally left test.only in the source code. */ + forbidOnly: false, + /* Retry on CI only */ + retries: 2, + /* Opt out of parallel tests on CI. */ + workers: 1, // required for now! todo parallel some tests + /* Reporter to use. See https://playwright.dev/docs/test-reporters */ + reporter: "line", + /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ + use: { + actionTimeout: 5000, + storageState: "loginAuth.json", + /* Base URL to use in actions like `await page.goto('/')`. */ + baseURL: "http://127.0.0.1", + + /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ + trace: "on-first-retry", + + /* Set default locale to English (US) */ + locale: "en-US", + }, + + /* Configure projects for major browsers */ + projects: [ + { + name: "firefox", + use: { ...devices["Desktop Firefox"] }, + }, + ], +}); diff --git a/backend/_docker/src/settings/backend/config.yaml b/backend/_docker/src/settings/backend/config.yaml new file mode 100644 index 0000000000..b8b1ef2115 --- /dev/null +++ b/backend/_docker/src/settings/backend/config.yaml @@ -0,0 +1,27 @@ +server: + port: 80 + baseURL: "/" + logging: + - levels: "info|error|debug" + sources: + - path: "../frontend/tests/playwright-files" + name: "playwright + files" + config: + defaultEnabled: true + - path: "." + name: "docker" + config: + disableIndexing: true + defaultEnabled: true +frontend: + name: "Graham's Filebrowser" + disableDefaultLinks: true + styling: + customThemes: + no-rounded: + description: "No rounded corners" # The description of the theme to display in the UI. + css: "no-rounded.css" # The css file path and filename to use for the theme. + externalLinks: + - text: "A playwright test" + url: "https://playwright.dev/" + title: "Playwright" \ No newline at end of file diff --git a/backend/_docker/src/settings/frontend/playwright.config.ts b/backend/_docker/src/settings/frontend/playwright.config.ts new file mode 100644 index 0000000000..f1d9f76466 --- /dev/null +++ b/backend/_docker/src/settings/frontend/playwright.config.ts @@ -0,0 +1,47 @@ +import { defineConfig, devices } from "@playwright/test"; + +/** + * Read environment variables from file. + * https://github.com/motdotla/dotenv + */ +// require('dotenv').config(); + +/** + * See https://playwright.dev/docs/test-configuration. + */ +export default defineConfig({ + globalSetup: "./tests/playwright/global-setup", + timeout: 10000, + testDir: "./tests/playwright/settings", + /* Run tests in files in parallel */ + fullyParallel: false, + /* Fail the build on CI if you accidentally left test.only in the source code. */ + forbidOnly: false, + /* Retry on CI only */ + retries: 2, + /* Opt out of parallel tests on CI. */ + workers: 1, + /* Reporter to use. See https://playwright.dev/docs/test-reporters */ + reporter: "line", + /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ + use: { + actionTimeout: 5000, + storageState: "loginAuth.json", + /* Base URL to use in actions like `await page.goto('/')`. */ + baseURL: "http://127.0.0.1/", + + /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ + trace: "on-first-retry", + + /* Set default locale to English (US) */ + locale: "en-US", + }, + + /* Configure projects for major browsers */ + projects: [ + { + name: "firefox", + use: { ...devices["Desktop Firefox"] }, + }, + ], +}); diff --git a/backend/_docker/src/sharing/backend/config.yaml b/backend/_docker/src/sharing/backend/config.yaml new file mode 100644 index 0000000000..343335932e --- /dev/null +++ b/backend/_docker/src/sharing/backend/config.yaml @@ -0,0 +1,23 @@ +server: + port: 80 + baseURL: "/" + logging: + - levels: "info|error|debug" + sources: + - path: "../frontend/tests/playwright-files" + name: "playwright + files" + config: + defaultEnabled: true + - path: "." + name: "docker" + config: + private: true + defaultEnabled: true + +frontend: + name: "Graham's Filebrowser" + disableDefaultLinks: true + externalLinks: + - text: "A playwright test" + url: "https://playwright.dev/" + title: "Playwright" \ No newline at end of file diff --git a/backend/_docker/src/sharing/frontend/playwright.config.ts b/backend/_docker/src/sharing/frontend/playwright.config.ts new file mode 100644 index 0000000000..b2644cfa32 --- /dev/null +++ b/backend/_docker/src/sharing/frontend/playwright.config.ts @@ -0,0 +1,47 @@ +import { defineConfig, devices } from "@playwright/test"; + +/** + * Read environment variables from file. + * https://github.com/motdotla/dotenv + */ +// require('dotenv').config(); + +/** + * See https://playwright.dev/docs/test-configuration. + */ +export default defineConfig({ + globalSetup: "./tests/playwright/global-setup", + timeout: 10000, + testDir: "./tests/playwright/sharing", + /* Run tests in files in parallel */ + fullyParallel: false, + /* Fail the build on CI if you accidentally left test.only in the source code. */ + forbidOnly: false, + /* Retry on CI only */ + retries: 2, + /* Opt out of parallel tests on CI. */ + workers: 1, + /* Reporter to use. See https://playwright.dev/docs/test-reporters */ + reporter: "line", + /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ + use: { + actionTimeout: 5000, + storageState: "loginAuth.json", + /* Base URL to use in actions like `await page.goto('/')`. */ + baseURL: "http://127.0.0.1/", + + /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ + trace: "on-first-retry", + + /* Set default locale to English (US) */ + locale: "en-US", + }, + + /* Configure projects for major browsers */ + projects: [ + { + name: "firefox", + use: { ...devices["Desktop Firefox"] }, + }, + ], +});