Compare commits

..
48 Commits
Author SHA1 Message Date
Gina Häußge 8e4c1f5246 Merge branch 'staging/bugfix' 2023-03-02 16:07:26 +01:00
Charlie Powell d813a0cc86 ⬆️ Bump wrapt to fix Python 3.11 compatibility (#4530)
Fully tested on 3.7, 3.10 and 3.11 - any issues that did exist appear to have been resolved.
2023-03-02 16:06:30 +01:00
Gina Häußge 7489b3c398 Merge branch 'staging/bugfix' 2023-03-02 15:58:56 +01:00
Gina Häußge 6e009d2544 🔖 Preparing release of 1.8.7 2023-03-02 15:57:53 +01:00
Gina Häußge 59054cc1e5 🥅 Don't send None to Locale.parse
The latest version of Babel no longer supports this
but raises an error, which in turn leads to a
500 Server Error response here.

To fix this, we set a default for best_match.

Closes #4744
2023-03-02 15:57:43 +01:00
Nick Mattis fcb9eaebda ✏️ Minor updates to plugin getting started tutorial docs (#4736)
* some minor updates to plugin getting started tutorial docs

* fix helloworld to stay camelcase
2023-02-20 21:36:28 +00:00
Patrick J. Ames b151152c00 ✏️ Fix small grammar error in README.md (#4731)
"It also serves as central knowledge base" > "It also serves as a central knowledge base"
2023-02-18 14:25:21 +00:00
dependabot[bot]andGina Häußge a1d95dd44b Bump dessant/lock-threads from 2 to 4 (#4726)
* Bump dessant/lock-threads from 2 to 4

Bumps [dessant/lock-threads](https://github.com/dessant/lock-threads) from 2 to 4.
- [Release notes](https://github.com/dessant/lock-threads/releases)
- [Changelog](https://github.com/dessant/lock-threads/blob/master/CHANGELOG.md)
- [Commits](https://github.com/dessant/lock-threads/compare/v2...v4)

---
updated-dependencies:
- dependency-name: dessant/lock-threads
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* 👷‍♂️ Adjust input parameters

Names changed in v3

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Gina Häußge <gina@octoprint.org>
2023-02-10 13:08:19 +01:00
Gina Häußge c01216cfab 👷‍♂️ Only trigger docs build on specific branches
master, maintenance and devel only for now
2023-02-10 13:03:10 +01:00
dependabot[bot] a47b5187bb Bump robotology/gh-action-nightly-merge from 1.3.3 to 1.4.0
Bumps [robotology/gh-action-nightly-merge](https://github.com/robotology/gh-action-nightly-merge) from 1.3.3 to 1.4.0.
- [Release notes](https://github.com/robotology/gh-action-nightly-merge/releases)
- [Commits](https://github.com/robotology/gh-action-nightly-merge/compare/v1.3.3...v1.4.0)

---
updated-dependencies:
- dependency-name: robotology/gh-action-nightly-merge
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-09 21:56:02 +01:00
dependabot[bot] 40d71f1242 Bump peter-evans/repository-dispatch from 1 to 2
Bumps [peter-evans/repository-dispatch](https://github.com/peter-evans/repository-dispatch) from 1 to 2.
- [Release notes](https://github.com/peter-evans/repository-dispatch/releases)
- [Commits](https://github.com/peter-evans/repository-dispatch/compare/v1...v2)

---
updated-dependencies:
- dependency-name: peter-evans/repository-dispatch
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-09 18:02:03 +01:00
dependabot[bot] 3088c3be0b Bump actions/labeler from 3 to 4 (#4727)
Bumps [actions/labeler](https://github.com/actions/labeler) from 3 to 4.
- [Release notes](https://github.com/actions/labeler/releases)
- [Commits](https://github.com/actions/labeler/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/labeler
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-09 18:00:54 +01:00
Gina Häußge 135249c554 👷 Enable Dependabot for GitHub Actions 2023-02-09 17:25:55 +01:00
Gina Häußge 814c3a1519 👷 Migrate from set-output got $GITHUB_OUTPUT 2023-02-08 16:20:42 +01:00
Gina Häußge 68191cfbf4 💚 HTTP has \r\n line endings
So we need to strip \r, \n already gets taken care of
by the whole pipe. Also limit to first location header
just in case.
2023-01-18 17:38:26 +01:00
Gina Häußge c5b56ae11b 👷 Get rid of newline in version 2023-01-18 17:15:30 +01:00
Gina Häußge cc47b41bae 👷 Fetch latest release without any action
bash, curl, awk ftw
2023-01-18 17:06:43 +01:00
Gina Häußge 397de4e3a7 👷 Use original get-latest-release action 2023-01-18 16:47:37 +01:00
Gina Häußge 9179545c33 📝 Get rid of Twitter link, fix build status badge 2022-12-19 14:33:41 +01:00
Gina Häußge 7659c811f5 🚨 Fix pre-commit's flake8 location 2022-11-16 14:46:25 +01:00
Gina Häußge 7d336bd098 📝 Thou shall test in safe mode before opening bug reports 2022-11-12 14:53:19 +01:00
Gina Häußge a68916f05a 📝 Redirect to new sec policy on octoprint.org 2022-10-19 11:50:45 +02:00
Gina Häußge dfced1118a 👷 Update actions to Node 16 versions 2022-10-18 15:59:41 +02:00
Gina Häußge 588a1c4cc8 🔖 staging/bugfix is now 1.8.7.dev 2022-10-18 11:44:07 +02:00
Gina Häußge ab3ebf101f Merge branch 'staging/bugfix' 2022-10-18 10:42:21 +02:00
Gina Häußge 1875623f05 🔖 Prepare release of 1.8.6 2022-10-18 10:38:08 +02:00
Gina Häußge ac6240a3a3 🐛 Fix tornado download endpoint
Something broke during the initial fix for #4659.

Fixes #4659
2022-10-17 21:14:29 +02:00
Gina Häußge ae407492bc 🔖 staging/bugfix is now 1.8.6.dev 2022-10-17 17:16:48 +02:00
Gina Häußge de3a12999e Merge branch 'staging/bugfix' 2022-10-17 15:50:48 +02:00
Gina Häußge 395354212c 🔖 Preparing release of 1.8.5 2022-10-17 15:49:29 +02:00
Gina Häußge b38785a25a 🔒️ Make dependabot happy on e2e test dep 2022-10-12 15:12:56 +02:00
Gina Häußge f28a53f3e6 💚 Downgrade importlib-metadata in pre-commit
See https://stackoverflow.com/a/73932581
2022-10-12 13:45:36 +02:00
Gina Häußge d94e13e9dc 👷 Auto merge staging/bugfix & .../maintenance if possible 2022-10-12 13:02:10 +02:00
Gina Häußge eb9e144746 🐛 Explicitly declare storage for flask-limiter
Prevents warnings in latest versions.
2022-10-05 17:37:54 +02:00
Gina Häußge b4d0ed30ab 🐛 backup: fix file validation
Just going by name breaks backups
with arbitrary file names created
from CLI or the helper.

Instead of matching on the name, we
now check whether it's a zip and
contains a metadata.json.

Closes #4659
2022-10-05 17:03:14 +02:00
Gina Häußge 8e9c09a818 💚 Downgrade importlib-metadata in pre-commit
See https://stackoverflow.com/a/73932581
2022-10-05 15:10:59 +02:00
Gina Häußge 5091487719 🐛 Fix js getCookieSuffix for multi level paths
Also add Unit test coverage for getCookieSuffix and
getParsedBaseUrl.

Closes #4656
2022-10-05 13:21:07 +02:00
Gina Häußge 2f62feaaec 🔖 staging/bugfix is now 1.8.5.dev 2022-09-27 17:47:38 +02:00
Gina Häußge 27a576e352 🔖 Preparing release of 1.8.4 2022-09-27 15:48:12 +02:00
Gina Häußge 2703d528a3 📝 Forgot to mention a port relevant header 2022-09-27 15:46:20 +02:00
Gina Häußge be0d452ab9 🐛 Fix stale session reporting
Fix handling of `stale` reauthRequired in UI and
document it. Also send it in case of an `auth`
message with an unknown session.

Closes #4653
2022-09-27 13:43:32 +02:00
Gina Häußge 0093d96da4 🚸 Downgrade SameSite setting to Lax
Strict was causing issues for users who navigate
to their OctoPrint instance using a custom start
page, since `SameSite=Strict` would suppress
all cookies in that case, forcing you to login
again.
2022-09-27 13:28:28 +02:00
Gina Häußge 73c199c98c ✨ Add a reverse proxy test page
Will show variables needed for URL generation and
cookie suffix generation, both as seen by client
and server, and highlight any mismatches.

Also links to the reverse proxy FAQ and includes
information on which request headers are
relevant.

Not translated, kept as simple as possible.

Not behind a login since none of this information
should be news to a client on a properly
configured proxy setup.
2022-09-27 13:20:27 +02:00
Gina Häußge f334decb33 🐛 Only enable argon2 if backend is available
We not only import it but also do a quick hash
and verify run to make sure the backend actually
works, otherwise we only support pbkdf2_sha256.

Additionally support multiple hash algorithms
and detect which one to use based on the password
hash.
2022-09-26 17:56:18 +02:00
Gina Häußge daa5dbc4d6 🐛 Fix setting CSRF cookie on cached responses
In case of a "Not modified" response, the CSRF cookie
wasn't added, leading to a loading failure.

Closes #4650
2022-09-26 12:19:26 +02:00
Gina Häußge 147d982c87 🐛 Fix invalid API key and guest behaviour vs CSRF
Closes second issue discovered in #4648
2022-09-22 18:52:06 +02:00
Gina Häußge b87b965fc5 🐛 Fix global API key vs session sigs
Closes #4648
2022-09-22 17:45:33 +02:00
Gina Häußge 9bc2d54196 🔖 staging/bugfix is now 1.8.4.dev 2022-09-20 14:57:10 +02:00
37 changed files with 556 additions and 143 deletions

No files matched your search

+2 -2
View File
@@ -76,10 +76,10 @@ body:
Issues caused by a third party plugin are a major cause of bugs reported here, so we really need to Issues caused by a third party plugin are a major cause of bugs reported here, so we really need to
rule out that a plugin is at fault here. [Safe mode](https://docs.octoprint.org/en/master/features/safemode.html) is an easy way to do that. Only skip safe mode rule out that a plugin is at fault here. [Safe mode](https://docs.octoprint.org/en/master/features/safemode.html) is an easy way to do that. Only skip safe mode
if your particular problem *absolutely requires* third party plugins to be enabled. "It would take if your particular problem *absolutely requires* third party plugins to be enabled. "It would take
too long" is **not** a reason to skip testing in safe mode, neither is "I do not know how to too long" or "I have a long print running right now" are **not** a reason to skip testing in safe mode, neither is "I do not know how to
enable it" as you can find info on that [here](https://docs.octoprint.org/en/master/features/safemode.html). enable it" as you can find info on that [here](https://docs.octoprint.org/en/master/features/safemode.html).
If you really *cannot* test in safe mode, leave a short explanation as to why. If you really *cannot* test in safe mode at all, leave a short explanation as to why. If you,can but just not right now, then wait with reporting until you can.
- type: markdown - type: markdown
attributes: attributes:
value: | value: |
+7
View File
@@ -0,0 +1,7 @@
version: 2
updates:
# Check for updates to GitHub Actions every week
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
+3
View File
@@ -15,7 +15,10 @@ meta:
ci/cd: ci/cd:
- ".github/fixtures/**/*" - ".github/fixtures/**/*"
- ".github/workflows/*" - ".github/workflows/*"
- ".github/dependabot.yml"
- ".github/issue-validation.yml"
- ".github/labeler.yml" - ".github/labeler.yml"
- ".github/pr-validation.yml"
docker: docker:
- ".github/workflows/trigger_docker.yml" - ".github/workflows/trigger_docker.yml"
+32 -17
View File
@@ -11,11 +11,11 @@ jobs:
name: 🔨 Build distribution name: 🔨 Build distribution
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
with: with:
fetch-depth: 0 fetch-depth: 0
- name: 🏗 Set up Python 3.7 - name: 🏗 Set up Python 3.7
uses: actions/setup-python@v1 uses: actions/setup-python@v4
with: with:
python-version: 3.7 python-version: 3.7
- name: 🏗 Install build dependencies - name: 🏗 Install build dependencies
@@ -25,7 +25,7 @@ jobs:
run: | run: |
python setup.py sdist bdist_wheel python setup.py sdist bdist_wheel
- name: ⬆ Upload build result - name: ⬆ Upload build result
uses: actions/upload-artifact@v1 uses: actions/upload-artifact@v3
with: with:
name: dist name: dist
path: dist path: dist
@@ -34,9 +34,9 @@ jobs:
name: 🧹 Pre-commit name: 🧹 Pre-commit
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: 🏗 Set up Python 3.7 - name: 🏗 Set up Python 3.7
uses: actions/setup-python@v1 uses: actions/setup-python@v4
with: with:
python-version: 3.7 python-version: 3.7
- name: 🏗 Set up dev dependencies - name: 🏗 Set up dev dependencies
@@ -53,9 +53,9 @@ jobs:
python: ["3.7", "3.8", "3.9", "3.10"] python: ["3.7", "3.8", "3.9", "3.10"]
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: 🏗 Set up Python ${{ matrix.python }} - name: 🏗 Set up Python ${{ matrix.python }}
uses: actions/setup-python@v1 uses: actions/setup-python@v4
with: with:
python-version: ${{ matrix.python }} python-version: ${{ matrix.python }}
- name: 🏗 Set up test dependencies - name: 🏗 Set up test dependencies
@@ -65,6 +65,20 @@ jobs:
run: | run: |
pytest pytest
test-js-unit:
name: 🧪 JavaScript unit tests
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: 🏗 Set up test dependencies
run: |
npm -g install node-qunit-puppeteer@2.1.0
- name: 🚀 Run helpers.js test suite
run: |
node-qunit-puppeteer tests/static/js/test-helpers.html
node-qunit-puppeteer tests/static/js/test-client-base.html
test-install: test-install:
name: 🧪 Installation tests name: 🧪 Installation tests
needs: build needs: build
@@ -75,12 +89,12 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: ⬇ Download build result - name: ⬇ Download build result
uses: actions/download-artifact@v1 uses: actions/download-artifact@v3
with: with:
name: dist name: dist
path: dist path: dist
- name: 🏗 Set up Python ${{ matrix.python }} - name: 🏗 Set up Python ${{ matrix.python }}
uses: actions/setup-python@v1 uses: actions/setup-python@v4
with: with:
python-version: ${{ matrix.python }} python-version: ${{ matrix.python }}
- name: 🚀 Install wheel - name: 🚀 Install wheel
@@ -99,15 +113,15 @@ jobs:
continue-on-error: true continue-on-error: true
steps: steps:
- name: ⬇ Checkout code - name: ⬇ Checkout code
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: ⬇ Download build result - name: ⬇ Download build result
uses: actions/download-artifact@v1 uses: actions/download-artifact@v3
with: with:
name: dist name: dist
path: dist path: dist
- name: 🏗 Set up Python 3.7 - name: 🏗 Set up Python 3.7
uses: actions/setup-python@v1 uses: actions/setup-python@v4
with: with:
python-version: 3.7 python-version: 3.7
- name: 🚀 Install wheel - name: 🚀 Install wheel
@@ -120,7 +134,7 @@ jobs:
cp -r .github/fixtures/with_acl/* e2econfig cp -r .github/fixtures/with_acl/* e2econfig
- name: 🚀 Run Cypress - name: 🚀 Run Cypress
uses: cypress-io/github-action@v2 uses: cypress-io/github-action@v4.2.0
with: with:
working-directory: tests/cypress working-directory: tests/cypress
browser: chrome browser: chrome
@@ -128,7 +142,7 @@ jobs:
wait-on: "http://127.0.0.1:5000/online.txt" wait-on: "http://127.0.0.1:5000/online.txt"
- name: ⬆ Upload screenshots - name: ⬆ Upload screenshots
uses: actions/upload-artifact@v1 uses: actions/upload-artifact@v3
if: failure() if: failure()
with: with:
name: cypress-screenshots name: cypress-screenshots
@@ -146,12 +160,13 @@ jobs:
needs: needs:
- pre-commit - pre-commit
- test-unit - test-unit
- test-js-unit
- test-install - test-install
- test-e2e - test-e2e
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: ⬇ Download build result - name: ⬇ Download build result
uses: actions/download-artifact@v1 uses: actions/download-artifact@v3
with: with:
name: dist name: dist
path: dist path: dist
@@ -169,7 +184,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: ⬇ Download build result - name: ⬇ Download build result
uses: actions/download-artifact@v1 uses: actions/download-artifact@v3
with: with:
name: dist name: dist
path: dist path: dist
@@ -189,7 +204,7 @@ jobs:
OCTOPRINT_VERSION=$(echo $GITHUB_REF | cut -d/ -f3) OCTOPRINT_VERSION=$(echo $GITHUB_REF | cut -d/ -f3)
echo "OCTOPRINT_VERSION=$OCTOPRINT_VERSION" >> $GITHUB_ENV echo "OCTOPRINT_VERSION=$OCTOPRINT_VERSION" >> $GITHUB_ENV
- name: 🚀 Repository Dispatch - name: 🚀 Repository Dispatch
uses: peter-evans/repository-dispatch@v1 uses: peter-evans/repository-dispatch@v2
with: with:
token: ${{ secrets.REPODISPATCH_TOKEN }} token: ${{ secrets.REPODISPATCH_TOKEN }}
repository: OctoPrint/OctoPi-UpToDate repository: OctoPrint/OctoPi-UpToDate
+4 -4
View File
@@ -10,11 +10,11 @@ jobs:
name: 🔒 Lock issues & PRs closed over a year name: 🔒 Lock issues & PRs closed over a year
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: dessant/lock-threads@v2 - uses: dessant/lock-threads@v4
with: with:
github-token: ${{ github.token }} github-token: ${{ github.token }}
issue-lock-comment: "" issue-comment: ""
pr-lock-comment: "" pr-comment: ""
cleanup: cleanup:
name: 🧹 Close issues marked as incomplete & older than 14 days name: 🧹 Close issues marked as incomplete & older than 14 days
@@ -22,7 +22,7 @@ jobs:
steps: steps:
- id: date - id: date
run: | run: |
echo "::set-output name=CUTOFF::`date --date='14 days ago' +'%Y-%m-%d'`" echo "CUTOFF=`date --date='14 days ago' +'%Y-%m-%d'`" >> $GITHUB_OUTPUT
- uses: OctoPrint/actions/close-by-query@main - uses: OctoPrint/actions/close-by-query@main
with: with:
repo-token: "${{ secrets.GITHUB_TOKEN }}" repo-token: "${{ secrets.GITHUB_TOKEN }}"
+2 -2
View File
@@ -7,7 +7,7 @@ jobs:
issue-automation: issue-automation:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/github-script@v5 - uses: actions/github-script@v6
with: with:
github-token: ${{ secrets.GITHUB_TOKEN }} github-token: ${{ secrets.GITHUB_TOKEN }}
script: | script: |
@@ -72,7 +72,7 @@ jobs:
# with: # with:
# repo-token: ${{ secrets.GITHUB_TOKEN }} # repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/github-script@v5 - uses: actions/github-script@v6
env: env:
REMINDER: > REMINDER: >
Hi @${{ github.event.issue.user.login }}! Hi @${{ github.event.issue.user.login }}!
+3 -3
View File
@@ -7,7 +7,7 @@ jobs:
linkifyBundles: linkifyBundles:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/github-script@v2 - uses: actions/github-script@v6
with: with:
github-token: ${{ secrets.GITHUB_TOKEN }} github-token: ${{ secrets.GITHUB_TOKEN }}
script: | script: |
@@ -38,14 +38,14 @@ jobs:
}); });
text += "\n*edited by @github-actions to add bundle viewer links*\n"; text += "\n*edited by @github-actions to add bundle viewer links*\n";
github.issues.updateComment({ github.rest.issues.updateComment({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
comment_id: context.payload.comment.id, comment_id: context.payload.comment.id,
body: text body: text
}); });
} else if (botWasHere !== -1) { } else if (botWasHere !== -1) {
github.issues.updateComment({ github.rest.issues.updateComment({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
comment_id: context.payload.comment.id, comment_id: context.payload.comment.id,
+21 -3
View File
@@ -10,12 +10,12 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: ⬇ Checkout - name: ⬇ Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
with: with:
fetch-depth: 0 fetch-depth: 0
- name: 🔀 Merge master into maintenance - name: 🔀 Merge master into maintenance
uses: robotology/gh-action-nightly-merge@v1.3.3 uses: robotology/gh-action-nightly-merge@v1.4.0
with: with:
stable_branch: "master" stable_branch: "master"
development_branch: "maintenance" development_branch: "maintenance"
@@ -23,8 +23,26 @@ jobs:
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: 🔀 Merge staging/bugfix into maintenance
uses: robotology/gh-action-nightly-merge@v1.4.0
with:
stable_branch: "staging/bugfix"
development_branch: "maintenance"
allow_ff: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: 🔀 Merge staging/maintenance into maintenance
uses: robotology/gh-action-nightly-merge@v1.4.0
with:
stable_branch: "staging/bugfix"
development_branch: "maintenance"
allow_ff: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: 🔀 Merge maintenance into devel - name: 🔀 Merge maintenance into devel
uses: robotology/gh-action-nightly-merge@v1.3.3 uses: robotology/gh-action-nightly-merge@v1.4.0
with: with:
stable_branch: "maintenance" stable_branch: "maintenance"
development_branch: "devel" development_branch: "devel"
+2 -2
View File
@@ -8,11 +8,11 @@ jobs:
pr-automation: pr-automation:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/labeler@v3 - uses: actions/labeler@v4
with: with:
repo-token: "${{ secrets.GITHUB_TOKEN }}" repo-token: "${{ secrets.GITHUB_TOKEN }}"
- uses: actions/github-script@v5 - uses: actions/github-script@v6
with: with:
github-token: ${{ secrets.GITHUB_TOKEN }} github-token: ${{ secrets.GITHUB_TOKEN }}
script: | script: |
+9 -10
View File
@@ -19,11 +19,11 @@ jobs:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- name: 🐍 Set up Python ${{ matrix.python }} - name: 🐍 Set up Python ${{ matrix.python }}
uses: actions/setup-python@v2 uses: actions/setup-python@v4
with: with:
python-version: ${{ matrix.python }} python-version: ${{ matrix.python }}
- name: ⬇ Checkout code - name: ⬇ Checkout code
uses: actions/checkout@v2 uses: actions/checkout@v3
with: with:
ref: ${{ matrix.branch }} ref: ${{ matrix.branch }}
fetch-depth: 0 fetch-depth: 0
@@ -55,24 +55,23 @@ jobs:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- name: 👀 Determine latest release - name: 👀 Determine latest release
id: latest run: |
uses: foosel/github-action-get-latest-release@master OCTOPRINT_VERSION=$(curl -i https://github.com/OctoPrint/OctoPrint/releases/latest | grep -i location: | head -n1 | awk -F/ '{print $NF}' | tr -d '\r')
with: echo "OCTOPRINT_VERSION=$OCTOPRINT_VERSION" >> $GITHUB_ENV
repository: "OctoPrint/OctoPrint"
- name: 🐍 Set up Python ${{ matrix.python }} - name: 🐍 Set up Python ${{ matrix.python }}
uses: actions/setup-python@v2 uses: actions/setup-python@v4
with: with:
python-version: ${{ matrix.python }} python-version: ${{ matrix.python }}
- name: 👷 Build and install latest release - name: 👷 Build and install latest release
run: | run: |
pip install https://github.com/OctoPrint/OctoPrint/archive/${{ steps.latest.outputs.release }}.zip pip install https://github.com/OctoPrint/OctoPrint/archive/${{ env.OCTOPRINT_VERSION }}.zip
- name: 📧 Discord success notification - name: 📧 Discord success notification
continue-on-error: true continue-on-error: true
env: env:
DISCORD_WEBHOOK: ${{ secrets.discord_webhook }} DISCORD_WEBHOOK: ${{ secrets.discord_webhook }}
uses: Ilshidur/action-discord@master uses: Ilshidur/action-discord@master
with: with:
args: "☑️ Test install on Python ${{ matrix.python }} under `${{ matrix.os }}` for `OctoPrint/OctoPrint:${{ steps.latest.outputs.release }}` was successful" args: "☑️ Test install on Python ${{ matrix.python }} under `${{ matrix.os }}` for `OctoPrint/OctoPrint:${{ env.OCTOPRINT_VERSION }}` was successful"
- name: 📧 Discord failure notification - name: 📧 Discord failure notification
continue-on-error: true continue-on-error: true
if: failure() if: failure()
@@ -80,4 +79,4 @@ jobs:
DISCORD_WEBHOOK: ${{ secrets.discord_webhook }} DISCORD_WEBHOOK: ${{ secrets.discord_webhook }}
uses: Ilshidur/action-discord@master uses: Ilshidur/action-discord@master
with: with:
args: "🚫 Test install on Python ${{ matrix.python }} under `${{ matrix.os }}` for `OctoPrint/OctoPrint:${{ steps.latest.outputs.release }}` failed" args: "🚫 Test install on Python ${{ matrix.python }} under `${{ matrix.os }}` for `OctoPrint/OctoPrint:${{ env.OCTOPRINT_VERSION }}` failed"
+3 -3
View File
@@ -15,7 +15,7 @@ jobs:
if: github.repository == 'OctoPrint/OctoPrint' && github.event_name != 'push' if: github.repository == 'OctoPrint/OctoPrint' && github.event_name != 'push'
steps: steps:
- name: 🚀 Repository Dispatch - name: 🚀 Repository Dispatch
uses: peter-evans/repository-dispatch@v1 uses: peter-evans/repository-dispatch@v2
with: with:
token: ${{ secrets.DOCKER_ACCESS_TOKEN }} token: ${{ secrets.DOCKER_ACCESS_TOKEN }}
repository: ${{ github.repository_owner }}/octoprint-docker repository: ${{ github.repository_owner }}/octoprint-docker
@@ -27,7 +27,7 @@ jobs:
if: github.repository == 'OctoPrint/OctoPrint' && github.event_name == 'push' && github.ref == 'refs/heads/maintenance' if: github.repository == 'OctoPrint/OctoPrint' && github.event_name == 'push' && github.ref == 'refs/heads/maintenance'
steps: steps:
- name: 🚀 Repository Dispatch - name: 🚀 Repository Dispatch
uses: peter-evans/repository-dispatch@v1 uses: peter-evans/repository-dispatch@v2
with: with:
token: ${{ secrets.DOCKER_ACCESS_TOKEN }} token: ${{ secrets.DOCKER_ACCESS_TOKEN }}
repository: ${{ github.repository_owner }}/octoprint-docker repository: ${{ github.repository_owner }}/octoprint-docker
@@ -39,7 +39,7 @@ jobs:
if: github.repository == 'OctoPrint/OctoPrint' && github.event_name == 'push' && github.ref == 'refs/heads/devel' if: github.repository == 'OctoPrint/OctoPrint' && github.event_name == 'push' && github.ref == 'refs/heads/devel'
steps: steps:
- name: 🚀 Repository Dispatch - name: 🚀 Repository Dispatch
uses: peter-evans/repository-dispatch@v1 uses: peter-evans/repository-dispatch@v2
with: with:
token: ${{ secrets.DOCKER_ACCESS_TOKEN }} token: ${{ secrets.DOCKER_ACCESS_TOKEN }}
repository: ${{ github.repository_owner }}/octoprint-docker repository: ${{ github.repository_owner }}/octoprint-docker
+5 -1
View File
@@ -1,6 +1,10 @@
name: Trigger doc build name: Trigger doc build
on: on:
push: push:
branches:
- master
- maintenance
- devel
release: release:
types: types:
- released - released
@@ -12,7 +16,7 @@ jobs:
if: github.repository == 'OctoPrint/OctoPrint' if: github.repository == 'OctoPrint/OctoPrint'
steps: steps:
- name: 🚀 Repository Dispatch - name: 🚀 Repository Dispatch
uses: peter-evans/repository-dispatch@v1 uses: peter-evans/repository-dispatch@v2
with: with:
token: ${{ secrets.REPODISPATCH_TOKEN }} token: ${{ secrets.REPODISPATCH_TOKEN }}
repository: OctoPrint/docs.octoprint.org repository: OctoPrint/docs.octoprint.org
+2 -1
View File
@@ -49,12 +49,13 @@ repos:
args: ["--config", "black.toml"] args: ["--config", "black.toml"]
additional_dependencies: additional_dependencies:
- click==8.0.4 - click==8.0.4
- repo: https://gitlab.com/pycqa/flake8 - repo: https://github.com/pycqa/flake8
rev: 3.9.2 rev: 3.9.2
hooks: hooks:
- id: flake8 - id: flake8
additional_dependencies: additional_dependencies:
- flake8-bugbear==22.1.11 - flake8-bugbear==22.1.11
- importlib-metadata<5.0
- repo: https://github.com/pre-commit/mirrors-prettier - repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.5.1 rev: v2.5.1
hooks: hooks:
+3 -3
View File
@@ -24,10 +24,10 @@ maintenance 1.8.0 3fe45661cd79c5137d9d4f5f4adb4d9519bc2084 pep440-dev
fix/.* 1.8.0 3fe45661cd79c5137d9d4f5f4adb4d9519bc2084 pep440-dev fix/.* 1.8.0 3fe45661cd79c5137d9d4f5f4adb4d9519bc2084 pep440-dev
improve/.* 1.8.0 3fe45661cd79c5137d9d4f5f4adb4d9519bc2084 pep440-dev improve/.* 1.8.0 3fe45661cd79c5137d9d4f5f4adb4d9519bc2084 pep440-dev
# staging/bugfix is the branch for preparation of the 1.8.3 bugfix release # staging/bugfix is the branch for preparation of the 1.8.7 bugfix release
# so are any bug/... branches # so are any bug/... branches
staging/bugfix 1.8.3 87f4a4e8c967dab147beb6213cbf61cca32bec62 pep440-dev staging/bugfix 1.8.7 1875623f05e14c3a197c6ff324f02dce55cec7d2 pep440-dev
bug/.* 1.8.3 87f4a4e8c967dab147beb6213cbf61cca32bec62 pep440-dev bug/.* 1.8.7 1875623f05e14c3a197c6ff324f02dce55cec7d2 pep440-dev
# staging/maintenance is currently the branch for preparation of 1.8.0rc6 # staging/maintenance is currently the branch for preparation of 1.8.0rc6
# so is regressionfix/... # so is regressionfix/...
+3 -4
View File
@@ -5,10 +5,9 @@
<p align="center"> <p align="center">
<img src="https://img.shields.io/github/v/release/OctoPrint/OctoPrint?logo=github&logoColor=white" alt="GitHub release"/> <img src="https://img.shields.io/github/v/release/OctoPrint/OctoPrint?logo=github&logoColor=white" alt="GitHub release"/>
<img src="https://img.shields.io/pypi/v/OctoPrint?logo=python&logoColor=white" alt="PyPI"/> <img src="https://img.shields.io/pypi/v/OctoPrint?logo=python&logoColor=white" alt="PyPI"/>
<img src="https://img.shields.io/github/workflow/status/OctoPrint/OctoPrint/Build" alt="Build status"/> <img src="https://img.shields.io/github/actions/workflow/status/OctoPrint/OctoPrint/build.yml?branch=master" alt="Build status"/>
<a href="https://community.octoprint.org"><img src="https://img.shields.io/discourse/users?logo=discourse&logoColor=white&server=https%3A%2F%2Fcommunity.octoprint.org" alt="Community Forum"/></a> <a href="https://community.octoprint.org"><img src="https://img.shields.io/discourse/users?label=forum&logo=discourse&logoColor=white&server=https%3A%2F%2Fcommunity.octoprint.org" alt="Community Forum"/></a>
<a href="https://discord.octoprint.org"><img src="https://img.shields.io/discord/704958479194128507?label=discord&logo=discord&logoColor=white" alt="Discord"/></a> <a href="https://discord.octoprint.org"><img src="https://img.shields.io/discord/704958479194128507?label=discord&logo=discord&logoColor=white" alt="Discord"/></a>
<a href="https://twitter.com/OctoPrint3d"><img src="https://img.shields.io/twitter/follow/OctoPrint3d.svg?style=social&label=Follow" alt="Twitter Follow"/></a>
<a href="https://octoprint.org/conduct/"><img src="https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg" alt="Contributor Covenant"/></a> <a href="https://octoprint.org/conduct/"><img src="https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg" alt="Contributor Covenant"/></a>
<a href="https://github.com/psf/black"><img src="https://img.shields.io/badge/code%20style-black-000000.svg" alt="Code style: black"/></a> <a href="https://github.com/psf/black"><img src="https://img.shields.io/badge/code%20style-black-000000.svg" alt="Code style: black"/></a>
<a href="https://github.com/prettier/prettier"><img src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square" alt="Code style: prettier"/></a> <a href="https://github.com/prettier/prettier"><img src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square" alt="Code style: prettier"/></a>
@@ -21,7 +20,7 @@ and released under the [GNU Affero General Public License V3](https://www.gnu.or
Its website can be found at [octoprint.org](https://octoprint.org/?utm_source=github&utm_medium=readme). Its website can be found at [octoprint.org](https://octoprint.org/?utm_source=github&utm_medium=readme).
The community forum is available at [community.octoprint.org](https://community.octoprint.org/?utm_source=github&utm_medium=readme). It also serves as central knowledge base. The community forum is available at [community.octoprint.org](https://community.octoprint.org/?utm_source=github&utm_medium=readme). It also serves as a central knowledge base.
An invite to the Discord server can be found at [discord.octoprint.org](https://discord.octoprint.org). An invite to the Discord server can be found at [discord.octoprint.org](https://discord.octoprint.org).
+1 -9
View File
@@ -1,11 +1,3 @@
# Security Policy # Security Policy
## Supported Versions OctoPrint's security policy can be found [here](https://octoprint.org/security/).
Always update to the latest version of OctoPrint to keep up with security patches.
## Reporting a Vulnerability
Email to security@octoprint.org.
For the sake of the userbase of OctoPrint please always disclose responsibly and with a 90+ day window.
+7 -5
View File
@@ -11,39 +11,42 @@ thanks to everyone who contributed!
* Al Mucci * Al Mucci
* Arnljot Arntsen * Arnljot Arntsen
* Ash King * Ash King
* Ben Fritsch
* BigTreeTech * BigTreeTech
* Boris Hussein * Boris Hussein
* Brad Jackson * Brad Jackson
* Calvin Vette
* Christian Petropolis * Christian Petropolis
* Christian Wolf * Christian Wolf
* Christian Würthner * Christian Würthner
* Christoph Sigrist * Christoph Sigrist
* CooperSpartan
* Creality3D * Creality3D
* DeltaMaker 3D Printers * DeltaMaker 3D Printers
* Dennis Breining * Dennis Breining
* Douglas Floyd
* Ed Crump
* Ernesto Martinez * Ernesto Martinez
* Franziska Kunsmann * Franziska Kunsmann
* Hog Duske * Hog Duske
* Jacob Renstrom
* James Mackay * James Mackay
* Jeff Green * Jeff Green
* Jeff Moe * Jeff Moe
* jeffiel * jeffiel
* Jeremy Cole * Jeremy Cole
* John Cassel
* Julian Melo * Julian Melo
* Justin Kaufman * Justin Kaufman
* Kaile Riser * Kaile Riser
* Kazuhiro Ogura * Kazuhiro Ogura
* Kenneth Jiang * Kenneth Jiang
* Kurt Wubbels * Kurt Wubbels
* Kyle Menigoz
* Lachlan Bell * Lachlan Bell
* Lefteris Lertas * Lefteris Lertas
* LulzBot * LulzBot
* Makespace Madrid * Makespace Madrid
* Mark Greenwald * Mark Greenwald
* Mark Walker * Mark Walker
* Matt Van Itallie
* Michael Aumock * Michael Aumock
* Mike Kershaw * Mike Kershaw
* Mosaic Manufacturing * Mosaic Manufacturing
@@ -65,7 +68,6 @@ thanks to everyone who contributed!
* Stefan Krister * Stefan Krister
* Steve Dougherty * Steve Dougherty
* Steve Thompson * Steve Thompson
* TJ Horner
* Ulrich Kempken * Ulrich Kempken
and 2188 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel) or via [GitHub Sponsors](https://github.com/users/foosel/sponsorship)! and 2036 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel) or via [GitHub Sponsors](https://github.com/users/foosel/sponsorship)!
+1 -1
View File
@@ -30,7 +30,7 @@ following message types are currently available for usage by 3rd party clients:
* ``connected``: Initial connection information, sent only right after establishing the socket connection. See * ``connected``: Initial connection information, sent only right after establishing the socket connection. See
:ref:`the payload data model <sec-api-push-datamodel-connected>`. :ref:`the payload data model <sec-api-push-datamodel-connected>`.
* ``reauthRequired``: A reauthentication of the current login session is required. The ``reason`` parameter in the * ``reauthRequired``: A reauthentication of the current login session is required. The ``reason`` parameter in the
payload defines whether a full active login is necessary (values ``logout`` and ``removed``) or a simple passive payload defines whether a full active login is necessary (values ``logout``, ``stale``, ``removed``) or a simple passive
login will suffice (all other values). login will suffice (all other values).
* ``current``: Rate limited general state update, payload contains information about the printer's state, job progress, * ``current``: Rate limited general state update, payload contains information about the printer's state, job progress,
accumulated temperature points and log lines since last update. OctoPrint will send these updates when new information accumulated temperature points and log lines since last update. OctoPrint will send these updates when new information
+9 -2
View File
@@ -20,7 +20,7 @@ development environment::
$ virtualenv venv $ virtualenv venv
[...] [...]
$ source venv/bin/activate $ source venv/bin/activate
(venv) $ pip install -e .[develop,plugins] (venv) $ pip install -e '.[develop,plugins]'
[...] [...]
(venv) $ octoprint --help (venv) $ octoprint --help
Usage: octoprint [OPTIONS] COMMAND [ARGS]... Usage: octoprint [OPTIONS] COMMAND [ARGS]...
@@ -163,7 +163,7 @@ Then we can use the ``octoprint dev plugin:new`` command [#f1]_ to generate a ne
email [you@example.com]: you@somewhere.net email [you@example.com]: you@somewhere.net
github_username [you]: yourGithubName github_username [you]: yourGithubName
plugin_version [0.1.0]: 1.0.0 plugin_version [0.1.0]: 1.0.0
plugin_description [TODO]: A quick "Hello World" example plugin for OCtoPrint plugin_description [TODO]: A quick "Hello World" example plugin for OctoPrint
plugin_license [AGPLv3]: plugin_license [AGPLv3]:
plugin_homepage [https://github.com/yourGithubName/OctoPrint-Helloworld]: plugin_homepage [https://github.com/yourGithubName/OctoPrint-Helloworld]:
plugin_source [https://github.com/yourGithubName/OctoPrint-Helloworld]: plugin_source [https://github.com/yourGithubName/OctoPrint-Helloworld]:
@@ -178,6 +178,9 @@ Then we can use the ``octoprint dev plugin:new`` command [#f1]_ to generate a ne
This will create a project structure in the ``OctoPrint-HelloWorld`` folder we just changed to that looks like this:: This will create a project structure in the ``OctoPrint-HelloWorld`` folder we just changed to that looks like this::
extras/ extras/
github/
bug_report.yml
feature_request.yml
README.txt README.txt
helloworld.md helloworld.md
octoprint_helloworld/ octoprint_helloworld/
@@ -200,6 +203,7 @@ This will create a project structure in the ``OctoPrint-HelloWorld`` folder we j
README.md README.md
requirements.txt requirements.txt
setup.py setup.py
setup.cfg
While we'll need some of those folders later on, we'll now delete everything that we don't need right now first, that While we'll need some of those folders later on, we'll now delete everything that we don't need right now first, that
will make it easier to understand what folder does what later on. Delete the following folders and anything in them: will make it easier to understand what folder does what later on. Delete the following folders and anything in them:
@@ -219,6 +223,7 @@ The final project structure should look like this for now::
MANIFEST.in MANIFEST.in
README.md README.md
requirements.txt requirements.txt
setup.cfg
setup.py setup.py
Out of curiosity, take a look into the ``setup.py`` file. The cookiecutter template should have prefilled all the Out of curiosity, take a look into the ``setup.py`` file. The cookiecutter template should have prefilled all the
@@ -393,6 +398,7 @@ Our plugin's directory structure should now look like this::
README.md README.md
requirements.txt requirements.txt
setup.py setup.py
setup.cfg
Restart OctoPrint and open the web interface in your browser (make sure to clear your browser's cache!). Restart OctoPrint and open the web interface in your browser (make sure to clear your browser's cache!).
@@ -648,6 +654,7 @@ look like this::
README.md README.md
requirements.txt requirements.txt
setup.py setup.py
setup.cfg
We need to tell OctoPrint about this new static asset so that it will properly inject it into the page. For this we We need to tell OctoPrint about this new static asset so that it will properly inject it into the page. For this we
just need to subclass :class:`~octoprint.plugin.AssetPlugin` and override its method :func:`~octoprint.plugin.AssetPlugin.get_assets` just need to subclass :class:`~octoprint.plugin.AssetPlugin` and override its method :func:`~octoprint.plugin.AssetPlugin.get_assets`
+2 -2
View File
@@ -31,7 +31,7 @@ SETUP_REQUIRES = []
bundled_plugins = [ bundled_plugins = [
"OctoPrint-FileCheck>=2021.2.23", "OctoPrint-FileCheck>=2021.2.23",
"OctoPrint-FirmwareCheck>=2021.10.11", "OctoPrint-FirmwareCheck>=2021.10.11",
"OctoPrint-PiSupport>=2022.3.28", "OctoPrint-PiSupport>=2022.6.13",
] ]
core_deps = [ core_deps = [
"argon2_cffi>=21.3.0,<22", "argon2_cffi>=21.3.0,<22",
@@ -66,7 +66,7 @@ core_deps = [
"watchdog>=1,<2", "watchdog>=1,<2",
"websocket-client>=1.2.1,<2", "websocket-client>=1.2.1,<2",
"werkzeug>=2.0,<2.1", # breaking changes can happen on minor version increases, flask-login 0.5 is incompatible with 2.1 "werkzeug>=2.0,<2.1", # breaking changes can happen on minor version increases, flask-login 0.5 is incompatible with 2.1
"wrapt>=1.13.3,<1.14", "wrapt>=1.14,<1.15",
"zeroconf>=0.33,<0.34", # breaking changes can happen on minor version increases "zeroconf>=0.33,<0.34", # breaking changes can happen on minor version increases
"zipstream-ng>=1.3.4,<2.0.0", "zipstream-ng>=1.3.4,<2.0.0",
] ]
+33 -12
View File
@@ -10,6 +10,7 @@ import uuid
import wrapt import wrapt
from flask_login import AnonymousUserMixin, UserMixin from flask_login import AnonymousUserMixin, UserMixin
from passlib.hash import pbkdf2_sha256
from werkzeug.local import LocalProxy from werkzeug.local import LocalProxy
from octoprint.access.groups import Group, GroupChangeListener from octoprint.access.groups import Group, GroupChangeListener
@@ -19,10 +20,22 @@ from octoprint.util import atomic_write, deprecated, generate_api_key
from octoprint.util import get_fully_qualified_classname as fqcn from octoprint.util import get_fully_qualified_classname as fqcn
from octoprint.util import to_bytes, yaml from octoprint.util import to_bytes, yaml
password_hashers = []
try: try:
from passlib.hash import argon2 as passwordhash from passlib.hash import argon2
except ImportError:
from passlib.hash import pbkdf2_sha256 as passwordhash # test if we can actually hash and verify, if not we won't use this backend
hash = argon2.hash("test")
argon2.verify("test", hash)
password_hashers.append(argon2)
except Exception:
logging.getLogger(__name__).warning(
"Argon2 passlib backend is not available, not using it for password hashing"
)
password_hashers.append(pbkdf2_sha256)
class UserManager(GroupChangeListener): class UserManager(GroupChangeListener):
@@ -141,7 +154,7 @@ class UserManager(GroupChangeListener):
@staticmethod @staticmethod
def create_password_hash(password, *args, **kwargs): def create_password_hash(password, *args, **kwargs):
return passwordhash.hash(password) return password_hashers[0].hash(password)
@staticmethod @staticmethod
def create_legacy_password_hash(password, salt): def create_legacy_password_hash(password, salt):
@@ -177,8 +190,10 @@ class UserManager(GroupChangeListener):
def cleanup_legacy_hashes(self): def cleanup_legacy_hashes(self):
pass pass
def signature_key_for_user(self, username, salt=None): def signature_key_for_user(self, username, secret):
return self.create_password_hash(username, salt=salt) return hashlib.sha512(
to_bytes(username, encoding="utf-8", errors="replace") + to_bytes(secret)
).hexdigest()
def add_user(self, username, password, active, permissions, groups, overwrite=False): def add_user(self, username, password, active, permissions, groups, overwrite=False):
pass pass
@@ -809,14 +824,16 @@ class FilebasedUserManager(UserManager):
self._settings.remove(["accessControl", "salt"]) self._settings.remove(["accessControl", "salt"])
self._settings.save() self._settings.save()
def signature_key_for_user(self, username, salt=None): def signature_key_for_user(self, username, secret):
if username == "_api":
return super().signature_key_for_user(username, secret)
if username not in self._users: if username not in self._users:
raise UnknownUser(username) raise UnknownUser(username)
user = self._users[username] user = self._users[username]
return hashlib.sha512( return hashlib.sha512(
to_bytes(username + user._passwordHash, encoding="utf-8", errors="replace") to_bytes(username + user._passwordHash, encoding="utf-8", errors="replace")
+ to_bytes(salt) + to_bytes(secret)
).hexdigest() ).hexdigest()
def change_user_setting(self, username, key, value): def change_user_setting(self, username, key, value):
@@ -1169,10 +1186,14 @@ class User(UserMixin):
if legacy: if legacy:
return self._passwordHash == password return self._passwordHash == password
try: for password_hash in password_hashers:
return passwordhash.verify(password, self._passwordHash) if password_hash.identify(self._passwordHash):
except ValueError: try:
return False return password_hash.verify(password, self._passwordHash)
except ValueError:
pass
return False
def get_id(self): def get_id(self):
return self.get_name() return self.get_name()
+20 -15
View File
@@ -381,18 +381,21 @@ class BackupPlugin(
) )
from octoprint.util import is_hidden_path from octoprint.util import is_hidden_path
plugin_folder = self.get_plugin_data_folder()
def path_check(path):
joined = os.path.join(plugin_folder, path)
return not is_hidden_path(joined) and self._valid_backup(joined)
return [ return [
( (
r"/download/(.*)", r"/download/(.*)",
LargeResponseHandler, LargeResponseHandler,
{ {
"path": self.get_plugin_data_folder(), "path": plugin_folder,
"as_attachment": True, "as_attachment": True,
"path_validation": path_validation_factory( "path_validation": path_validation_factory(
lambda path: not is_hidden_path(path) path_check,
and self._match_backup_filename(
os.path.basename(path), self._settings
),
status_code=404, status_code=404,
), ),
"access_validation": access_validation_factory( "access_validation": access_validation_factory(
@@ -739,9 +742,7 @@ class BackupPlugin(
for entry in os.scandir(self.get_plugin_data_folder()): for entry in os.scandir(self.get_plugin_data_folder()):
if is_hidden_path(entry.path): if is_hidden_path(entry.path):
continue continue
if not entry.is_file(): if not self._valid_backup(entry.path):
continue
if not entry.name.endswith(".zip"):
continue continue
backups.append( backups.append(
@@ -1373,13 +1374,6 @@ class BackupPlugin(
backup_prefix, time.strftime(BACKUP_DATE_TIME_FMT) backup_prefix, time.strftime(BACKUP_DATE_TIME_FMT)
) )
@classmethod
def _match_backup_filename(cls, path, settings):
import re
backup_prefix = cls._get_backup_prefix(settings)
return re.match(re.escape(backup_prefix) + r"-backup-\d{8}-\d{6}.zip", path)
@classmethod @classmethod
def _get_backup_prefix(cls, settings): def _get_backup_prefix(cls, settings):
if settings.global_get(["appearance", "name"]) == "": if settings.global_get(["appearance", "name"]) == "":
@@ -1397,6 +1391,17 @@ class BackupPlugin(
not in valid_boolean_trues not in valid_boolean_trues
) )
@classmethod
def _valid_backup(cls, path):
if not path.endswith(".zip") or not zipfile.is_zipfile(path):
return False
try:
with zipfile.ZipFile(path) as z:
return "metadata.json" in z.namelist()
except Exception:
return False
def _send_client_message(self, message, payload=None): def _send_client_message(self, message, payload=None):
if payload is None: if payload is None:
payload = {} payload = {}
@@ -18,10 +18,10 @@ from octoprint.util.version import (
) )
SENTRY_URL_SERVER = ( SENTRY_URL_SERVER = (
"https://af30d06358144fb8af076ffd8984136d@o118517.ingest.sentry.io/1373987" "https://9c242ccf183444eaacd046d86d8b0ea2@o118517.ingest.sentry.io/1373987"
) )
SENTRY_URL_COREUI = ( SENTRY_URL_COREUI = (
"https://e1d6b5d760f241408382d62a3e7fb416@o118517.ingest.sentry.io/1374096" "https://4d9844043596415faa606ff722174b90@o118517.ingest.sentry.io/1374096"
) )
SETTINGS_DEFAULTS = { SETTINGS_DEFAULTS = {
@@ -158,7 +158,9 @@ def _enable_errortracking():
unique_id = str(uuid.uuid4()) unique_id = str(uuid.uuid4())
s.set( s.set(
["plugins", "errortracking", "unique_id"], unique_id, defaults=plugin_defaults ["plugins", "errortracking", "unique_id"],
unique_id,
defaults=plugin_defaults,
) )
s.save() s.save()
+2 -1
View File
@@ -1349,7 +1349,7 @@ class Server:
): ):
return Locale.negotiate([default_language], LANGUAGES) return Locale.negotiate([default_language], LANGUAGES)
return Locale.parse(request.accept_languages.best_match(LANGUAGES)) return Locale.parse(request.accept_languages.best_match(LANGUAGES, default="en"))
def _setup_heartbeat_logging(self): def _setup_heartbeat_logging(self):
logger = logging.getLogger(__name__ + ".heartbeat") logger = logging.getLogger(__name__ + ".heartbeat")
@@ -1472,6 +1472,7 @@ class Server:
app, app,
key_func=get_remote_address, key_func=get_remote_address,
enabled=s.getBoolean(["devel", "enableRateLimiter"]), enabled=s.getBoolean(["devel", "enableRateLimiter"]),
storage_uri="memory://",
) )
def _setup_i18n(self, app): def _setup_i18n(self, app):
+3 -3
View File
@@ -43,7 +43,7 @@ def loginFromApiKeyRequestHandler():
if loginUserFromApiKey(): if loginUserFromApiKey():
_flask.g.login_via_apikey = True _flask.g.login_via_apikey = True
except InvalidApiKeyException: except InvalidApiKeyException:
_flask.abort(403) _flask.abort(403, "Invalid API key")
def loginFromAuthorizationHeaderRequestHandler(): def loginFromAuthorizationHeaderRequestHandler():
@@ -54,7 +54,7 @@ def loginFromAuthorizationHeaderRequestHandler():
if loginUserFromAuthorizationHeader(): if loginUserFromAuthorizationHeader():
_flask.g.login_via_header = True _flask.g.login_via_header = True
except InvalidApiKeyException: except InvalidApiKeyException:
_flask.abort(403) _flask.abort(403, "Invalid credentials in Basic Authorization header")
class InvalidApiKeyException(Exception): class InvalidApiKeyException(Exception):
@@ -69,7 +69,7 @@ def loginUserFromApiKey():
user = get_user_for_apikey(apikey) user = get_user_for_apikey(apikey)
if user is None: if user is None:
# invalid API key = no API key # invalid API key = no API key
return False raise InvalidApiKeyException("Invalid API key")
return loginUser(user, login_mechanism="apikey") return loginUser(user, login_mechanism="apikey")
+4 -3
View File
@@ -65,7 +65,7 @@ def validate_csrf_tokens(cookie, header):
def add_csrf_cookie(response): def add_csrf_cookie(response):
if not isinstance(response, OctoPrintFlaskResponse): if not isinstance(response, OctoPrintFlaskResponse):
return response = flask.make_response(response)
token = generate_csrf_token() token = generate_csrf_token()
response.set_cookie("csrf_token", token, httponly=False) response.set_cookie("csrf_token", token, httponly=False)
@@ -77,8 +77,9 @@ def validate_csrf_request(request):
# Irrelevant method for CSRF, bypass # Irrelevant method for CSRF, bypass
return return
if getattr(flask.g, "login_via_apikey", False): session = getattr(flask, "session", {})
# API key authorization, bypass if len(session) == 0 or session.get("login_mechanism") == "apikey":
# empty session, not a browser context
return return
if is_exempt(request.endpoint): if is_exempt(request.endpoint):
+20 -15
View File
@@ -433,7 +433,7 @@ def encode_remember_me_cookie(value):
name = value.split("|")[0] name = value.split("|")[0]
try: try:
remember_key = userManager.signature_key_for_user( remember_key = userManager.signature_key_for_user(
name, salt=current_app.config["SECRET_KEY"] name, current_app.config["SECRET_KEY"]
) )
timestamp = datetime.utcnow().timestamp() timestamp = datetime.utcnow().timestamp()
return encode_cookie(f"{name}|{timestamp}", key=remember_key) return encode_cookie(f"{name}|{timestamp}", key=remember_key)
@@ -453,7 +453,7 @@ def decode_remember_me_cookie(value):
try: try:
# valid signature? # valid signature?
signature_key = userManager.signature_key_for_user( signature_key = userManager.signature_key_for_user(
name, salt=current_app.config["SECRET_KEY"] name, current_app.config["SECRET_KEY"]
) )
cookie = decode_cookie(value, key=signature_key) cookie = decode_cookie(value, key=signature_key)
if cookie: if cookie:
@@ -470,6 +470,20 @@ def decode_remember_me_cookie(value):
raise ValueError("Invalid remember me cookie") raise ValueError("Invalid remember me cookie")
def get_cookie_suffix(request):
"""
Request specific suffix for set and read cookies
We need this because cookies are not port-specific and we don't want to overwrite our
session and other cookies from one OctoPrint instance on our machine with those of another
one who happens to listen on the same address albeit a different port or script root.
"""
result = "_P" + request.server_port
if request.script_root:
return result + "_R" + request.script_root.replace("/", "|")
return result
class OctoPrintFlaskRequest(flask.Request): class OctoPrintFlaskRequest(flask.Request):
environment_wrapper = staticmethod(lambda x: x) environment_wrapper = staticmethod(lambda x: x)
@@ -518,17 +532,7 @@ class OctoPrintFlaskRequest(flask.Request):
@cached_property @cached_property
def cookie_suffix(self): def cookie_suffix(self):
""" return get_cookie_suffix(self)
Request specific suffix for set and read cookies
We need this because cookies are not port-specific and we don't want to overwrite our
session and other cookies from one OctoPrint instance on our machine with those of another
one who happens to listen on the same address albeit a different port or script root.
"""
result = "_P" + self.server_port
if self.script_root:
return result + "_R" + self.script_root.replace("/", "|")
return result
class OctoPrintFlaskResponse(flask.Response): class OctoPrintFlaskResponse(flask.Response):
@@ -1908,11 +1912,12 @@ class OctoPrintJsonEncoder(flask.json.JSONEncoder):
def session_signature(user, session): def session_signature(user, session):
from octoprint.server import userManager from octoprint.server import userManager
key = userManager.signature_key_for_user(user, salt=current_app.config["SECRET_KEY"]) key = userManager.signature_key_for_user(user, current_app.config["SECRET_KEY"])
return hmac.new( return hmac.new(
key.encode("utf-8"), session.encode("utf-8"), hashlib.sha512 key.encode("utf-8"), session.encode("utf-8"), hashlib.sha512
).hexdigest() ).hexdigest()
def validate_session_signature(sig, user, session): def validate_session_signature(sig, user, session):
return hmac.compare_digest(sig, session_signature(user, session)) user_sig = session_signature(user, session)
return len(user_sig) == len(sig) and hmac.compare_digest(sig, user_sig)
+1
View File
@@ -305,6 +305,7 @@ class PrinterStateConnection(
f"Unknown user/session combo: {user_id}:{user_session}" f"Unknown user/session combo: {user_id}:{user_session}"
) )
self._on_logout() self._on_logout()
self._sendReauthRequired("stale")
self._register() self._register()
+23 -6
View File
@@ -225,8 +225,7 @@ def login():
_logger.exception("Error processing theming CSS, ignoring") _logger.exception("Error processing theming CSS, ignoring")
resp = make_response(render_template("login.jinja2", **render_kwargs)) resp = make_response(render_template("login.jinja2", **render_kwargs))
add_csrf_cookie(resp) return add_csrf_cookie(resp)
return resp
@app.route("/recovery") @app.route("/recovery")
@@ -258,8 +257,7 @@ def recovery():
_logger.exception("Error adding backup upload size info, ignoring") _logger.exception("Error adding backup upload size info, ignoring")
resp = make_response(render_template("recovery.jinja2", **render_kwargs)) resp = make_response(render_template("recovery.jinja2", **render_kwargs))
add_csrf_cookie(resp) return add_csrf_cookie(resp)
return resp
@app.route("/cached.gif") @app.route("/cached.gif")
@@ -333,6 +331,26 @@ def in_cache():
return abort(404) return abort(404)
@app.route("/reverse_proxy_test")
@app.route("/reverse_proxy_test/")
def reverse_proxy_test():
from octoprint.server.util.flask import get_cookie_suffix, get_remote_address
remote_address = get_remote_address(request)
cookie_suffix = get_cookie_suffix(request)
return render_template(
"reverse_proxy_test.jinja2",
theming=[],
client_ip=remote_address,
server_protocol=request.environ.get("wsgi.url_scheme"),
server_name=request.environ.get("SERVER_NAME"),
server_port=request.environ.get("SERVER_PORT"),
server_path=request.script_root if request.script_root else "/",
cookie_suffix=cookie_suffix,
)
@app.route("/") @app.route("/")
def index(): def index():
from octoprint.server import connectivityChecker, printer from octoprint.server import connectivityChecker, printer
@@ -700,8 +718,7 @@ def index():
if response is None: if response is None:
return abort(404) return abort(404)
add_csrf_cookie(response) return add_csrf_cookie(response)
return response
def _get_render_kwargs(templates, plugin_names, plugin_vars, now): def _get_render_kwargs(templates, plugin_names, plugin_vars, now):
+1 -1
View File
@@ -228,7 +228,7 @@ default_settings = {
"preemptiveCache": {"exceptions": [], "until": 7}, "preemptiveCache": {"exceptions": [], "until": 7},
"ipCheck": {"enabled": True, "trustedSubnets": []}, "ipCheck": {"enabled": True, "trustedSubnets": []},
"allowFraming": False, "allowFraming": False,
"cookies": {"secure": False, "samesite": "strict"}, "cookies": {"secure": False, "samesite": "lax"},
}, },
"webcam": { "webcam": {
"webcamEnabled": True, "webcamEnabled": True,
+12 -3
View File
@@ -107,13 +107,14 @@
return url; return url;
}; };
OctoPrintClient.prototype.getCookieSuffix = function () { OctoPrintClient.prototype.getParsedBaseUrl = function (location) {
if (!this.options.baseurl) return ""; if (!this.options.baseurl) return "";
try { try {
var url = new URL(this.options.baseurl); var url = new URL(this.options.baseurl);
} catch (e) { } catch (e) {
var parsed = new URL(window.location); location = location || window.location;
var parsed = new URL(location);
var path = this.options.baseurl; var path = this.options.baseurl;
if (!path || path[0] !== "/") { if (!path || path[0] !== "/") {
path = "/" + (path ? path : ""); path = "/" + (path ? path : "");
@@ -121,13 +122,21 @@
var url = new URL(parsed.protocol + "//" + parsed.host + path); var url = new URL(parsed.protocol + "//" + parsed.host + path);
} }
return url;
};
OctoPrintClient.prototype.getCookieSuffix = function () {
if (!this.options.baseurl) return "";
var url = this.getParsedBaseUrl();
var port = url.port || (url.protocol === "https:" ? 443 : 80); var port = url.port || (url.protocol === "https:" ? 443 : 80);
if (url.pathname && url.pathname !== "/") { if (url.pathname && url.pathname !== "/") {
var path = url.pathname; var path = url.pathname;
if (path.endsWith("/")) { if (path.endsWith("/")) {
path = path.substring(0, path.length - 1); path = path.substring(0, path.length - 1);
} }
return "_P" + port + "_R" + path.replace(/\//, "|"); return "_P" + port + "_R" + path.replace(/\//g, "|");
} else { } else {
return "_P" + port; return "_P" + port;
} }
@@ -308,7 +308,7 @@ $(function () {
}; };
self.onDataUpdaterReauthRequired = function (reason) { self.onDataUpdaterReauthRequired = function (reason) {
if (reason === "logout" || reason === "removed") { if (reason === "logout" || reason === "stale" || reason === "removed") {
self.logout(); self.logout();
} else { } else {
self.requestData(); self.requestData();
@@ -0,0 +1,43 @@
$(function () {
//~~ OctoPrint client setup
var OctoPrint = window.OctoPrint;
OctoPrint.options.baseurl = BASE_URL;
//~~ Lodash setup
_.mixin({sprintf: sprintf, vsprintf: vsprintf});
//~~ View Model
function ReverseProxyTestViewModel() {
var self = this;
var url = OctoPrint.getParsedBaseUrl();
var cookieSuffix = OctoPrint.getCookieSuffix();
var protocol = url.protocol;
var path = url.pathname || "/";
if (path && path !== "/") {
if (path.endsWith("/")) {
path = path.substring(0, path.length - 1);
}
}
self.serverProtocol = protocol.substring(0, protocol.length - 1);
self.serverName = url.hostname;
self.serverPort = url.port || (url.protocol === "https:" ? 443 : 80);
self.serverPath = path;
self.cookieSuffix = cookieSuffix;
self.serverProtocolMatch = self.serverProtocol == SERVER_PROTOCOL;
self.serverNameMatch = self.serverName == SERVER_NAME;
self.serverPortMatch = self.serverPort == SERVER_PORT;
self.serverPathMatch = self.serverPath == SERVER_PATH;
self.cookieSuffixMatch = self.cookieSuffix == COOKIE_SUFFIX;
}
var viewModel = new ReverseProxyTestViewModel();
ko.applyBindings(viewModel, document.getElementById("reverse_proxy_test"));
});
@@ -0,0 +1,130 @@
<html>
<head>
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>OctoPrint Reverse Proxy Test</title>
<link rel="shortcut icon" href="{{ url_for('static', filename='img/tentacle-32x32.png') }}">
<link rel="mask-icon" href="{{ url_for('static', filename='img/mask.svg') }}" color="#56BE37">
<link rel="mask-icon-theme" href="{{ url_for('static', filename='img/mask-theme.svg') }}" color="#56BE37">
<link rel="apple-touch-icon" sizes="114x114" href="{{ url_for('static', filename='img/apple-touch-icon-114x114.png') }}">
<link rel="apple-touch-icon" sizes="144x144" href="{{ url_for('static', filename='img/apple-touch-icon-144x144.png') }}">
<!-- le CSS -->
<link rel="stylesheet" href="{{ url_for("static", filename="css/bootstrap.min.css") }}">
<link rel="stylesheet" href="{{ url_for("static", filename="css/bootstrap-responsive.min.css") }}">
<link rel="stylesheet" href="{{ url_for("static", filename="vendor/font-awesome-5.15.1/css/all.min.css") }}">
<link rel="stylesheet" href="{{ url_for("static", filename="vendor/font-awesome-5.15.1/css/v4-shims.min") }}">
{% for url in theming %}
<link rel="stylesheet" href="{{ url }}">
{% endfor %}
<!-- le javascript -->
<script>
var BASE_URL = "{{ url_for('index') }}";
var CLIENT_IP = "{{ client_ip }}";
var SERVER_PROTOCOL = "{{ server_protocol }}";
var SERVER_NAME = "{{ server_name }}";
var SERVER_PORT = {{ server_port }};
var SERVER_PATH = "{{ server_path }}";
var COOKIE_SUFFIX = "{{ cookie_suffix }}";
</script>
<script src="{{ url_for("static", filename="js/lib/jquery/jquery.min.js") }}"></script>
<script src="{{ url_for("static", filename="js/lib/knockout.js") }}"></script>
<script src="{{ url_for("static", filename="js/lib/bootstrap/bootstrap.js") }}"></script>
<script src="{{ url_for("static", filename="js/lib/lodash.min.js") }}"></script>
<script src="{{ url_for("static", filename="js/lib/sprintf.min.js") }}"></script>
{% assets "js_client" %}
<script type="text/javascript" src="{{ ASSET_URL }}"></script>
{% endassets %}
<script src="{{ url_for("static", filename="js/app/helpers.js") }}"></script>
<script src="{{ url_for("static", filename="js/reverse_proxy_test/reverse_proxy_test.js") }}"></script>
</head>
<body>
<div id="navbar" class="navbar navbar-inverse navbar-static-top">
<div class="navbar-inner">
<span class="brand">OctoPrint Reverse Proxy Test</span>
</div>
</div>
<div id="reverse_proxy_test" class="container" style="padding-top: 1em">
<div class="alert alert-error" data-bind="visible: !cookieSuffixMatch">
<strong>Warning!</strong> The used cookie suffix doesn't match between client and server. That means that OctoPrint's
UI won't work properly. Please check your configuration and fix it.
</div>
<p>
This page helps you identify issues in your reverse proxy configuration. It will show you information about
some of the variables that OctoPrint uses to set cookies and generate fully qualified URLs. If you see
any mismatches highlighted in red below, that means that something is not configured properly and you
need to fix it.
</p>
<p>
The table also shows you the client IP that your server saw you as. Make sure that this client IP is what
OctoPrint should be seeing, and not for example your reverse proxy itself.
</p>
<p>
For each variable, information is displayed what influences the value the server sees and thus where to
start debugging in case of any observed mismatches.
</p>
<table class="table table-bordered table-hover">
<thead>
<th>Variable</th>
<th>Source</th>
<th>Client</th>
<th>Server</th>
</thead>
<tr>
<td>Client IP</td>
<td><code>X-Forwarded-For</code></td>
<td>-</td>
<td>{{ client_ip }}</td>
</tr>
<tr data-bind="css: { success: serverProtocolMatch, error: !serverProtocolMatch }">
<td>Protocol</td>
<td><code>X-Forwarded-Protocol</code>, <code>X-Scheme</code> or config</td>
<td data-bind="text: serverProtocol"></td>
<td>{{ server_protocol }}</td>
</tr>
<tr data-bind="css: { success: serverNameMatch, error: !serverNameMatch }">
<td>Host</td>
<td><code>X-Forwarded-Host</code>, <code>Host</code>, <code>X-Forwarded-Server</code> or config</td>
<td data-bind="text: serverName"></td>
<td>{{ server_name }}</td>
</tr>
<tr data-bind="css: { success: serverPortMatch, error: !serverPortMatch }">
<td>Port</td>
<td><code>X-Forwarded-Host</code>, <code>Host</code>, <code>X-Forwarded-Port</code>, <code>X-Forwarded-Protocol</code>, <code>X-Scheme</code> or config</td>
<td data-bind="text: serverPort"></td>
<td>{{ server_port }}</td>
</tr>
<tr data-bind="css: { success: serverPathMatch, error: !serverPathMatch }">
<td>Path</td>
<td><code>X-Script-Name</code> or config</td>
<td data-bind="text: serverPath"></td>
<td>{{ server_path }}</td>
</tr>
<tr data-bind="css: { success: cookieSuffixMatch, error: !cookieSuffixMatch }">
<td>Cookie Suffix</td>
<td>Built from port & path</td>
<td data-bind="text: cookieSuffix"></td>
<td>{{ cookie_suffix }}</td>
</tr>
</table>
<p>
Please refer to <a href="https://faq.octoprint.org/reverse-proxy" target="_blank" rel="noopener noreferrer">the Reverse Proxy FAQ entry</a>
for information on correct configuration and examples.
</p>
</div>
</body>
</html>
+9 -6
View File
@@ -1237,9 +1237,12 @@
} }
}, },
"node_modules/minimist": { "node_modules/minimist": {
"version": "1.2.5", "version": "1.2.7",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.7.tgz",
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" "integrity": "sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
}, },
"node_modules/ms": { "node_modules/ms": {
"version": "2.1.2", "version": "2.1.2",
@@ -2602,9 +2605,9 @@
} }
}, },
"minimist": { "minimist": {
"version": "1.2.5", "version": "1.2.7",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.7.tgz",
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" "integrity": "sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g=="
}, },
"ms": { "ms": {
"version": "2.1.2", "version": "2.1.2",
+18
View File
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>src/octoprint/static/js/app/client/base.js Tests</title>
<link rel="stylesheet" href="lib/qunit-1.18.0.css" />
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<script src="lib/qunit-1.18.0.js"></script>
<script src="lib/qunit-parameterize.js"></script>
<script src="../../../src/octoprint/static/js/lib/lodash.min.js"></script>
<script src="../../../src/octoprint/static/js/lib/sprintf.min.js"></script>
<script src="../../../src/octoprint/static/js/app/client/base.js"></script>
<script src="test-client-base.js"></script>
</body>
</html>
+110
View File
@@ -0,0 +1,110 @@
_.mixin({sprintf: sprintf, vsprintf: vsprintf});
QUnit.module("getParsedBaseUrl");
QUnit.cases(
(function () {
return [
{
title: "fully qualified baseurl",
baseurl: "https://example.com",
location: undefined,
expected: "https://example.com/"
},
{
title: "fully qualified baseurl with http",
baseurl: "http://example.com",
location: undefined,
expected: "http://example.com/"
},
{
title: "fully qualified baseurl with custom port",
baseurl: "https://example.com:5000",
location: undefined,
expected: "https://example.com:5000/"
},
{
title: "website root",
baseurl: "/",
location: "https://example.com",
expected: "https://example.com/"
},
{
title: "website root with custom port",
baseurl: "/",
location: "https://example.com:5000",
expected: "https://example.com:5000/"
},
{
title: "single level prefix",
baseurl: "/octoprint/",
location: "https://example.com",
expected: "https://example.com/octoprint/"
},
{
title: "multi level prefix",
baseurl: "/path/to/octoprint/",
location: "https://example.com",
expected: "https://example.com/path/to/octoprint/"
},
{
title: "multi level prefix with http and custom port",
baseurl: "/path/to/octoprint/",
location: "http://example.com:5000",
expected: "http://example.com:5000/path/to/octoprint/"
},
{
title: "multi level prefix with https, custom port, no trailing slash",
baseurl: "/path/to/octoprint",
location: "https://example.com:5001",
expected: "https://example.com:5001/path/to/octoprint"
}
];
})()
).test("getParsedBaseUrl", function (params, assert) {
OctoPrint.options.baseurl = params.baseurl;
assert.equal(
OctoPrint.getParsedBaseUrl(params.location).toString(),
params.expected,
"Expected: " + String(params.expected)
);
});
QUnit.module("getCookieSuffix");
QUnit.cases(
(function () {
return [
{
title: "http with default port",
baseurl: "http://example.com",
expected: "_P80"
},
{
title: "https with default port",
baseurl: "https://example.com",
expected: "_P443"
},
{
title: "custom port",
baseurl: "http://example.com:5000",
expected: "_P5000"
},
{
title: "single level prefix",
baseurl: "https://example.com/octoprint/",
expected: "_P443_R|octoprint"
},
{
title: "multi level prefix",
baseurl: "https://example.com/path/to/octoprint",
expected: "_P443_R|path|to|octoprint"
}
];
})()
).test("getCookieSuffix", function (params, assert) {
OctoPrint.options.baseurl = params.baseurl;
assert.equal(
OctoPrint.getCookieSuffix(),
params.expected,
"Expected: " + String(params.expected)
);
});