Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow all authentication methods for asset downloads
Commit 4c8ed39 introduced an option to to restrict asset downloads to logged-in users. This was literally only allowing asset downloads to users that were logged-in using the web UI. To move this forward and implement https://progress.opensuse.org/issues/174301 it is required to allow other authentication our other API authentication methods as well. This change therefore enables the use of our normal API authentication methods for read-only asset routes by simply making use of the auth controller we normally use for API requests. If authentication for asset is not configured this has of course no effect. This allows queries like to return the expected 200/302 response (or 403 in case the specified credentials are wrong). ``` curl -i -u Demo:…:… 'http://localhost:9526/assets/other/openSUSE-Tumbleweed-DVD-x86_64-Snapshot20230109-Media.iso.sha256' curl -i -u Demo:…:… 'http://localhost:9526/tests/4416/asset/other/openSUSE-Tumbleweed-DVD-x86_64-Snapshot20250112-Media.iso.sha256' ``` Before, these queries would instead always redirect to the login route of the web UI. The change to the web API routes alone would break asset downloads via links on the web UI as those routes would now always require the CSRF token to be supplied. This commit therefore also changes the API auth controller to allow GET requests without CSRF token. We already allow GET requests without CSRF token on all web UI routes in the session controller so this should be fine. (Additionally, browsers disallow cross-site scripting out of the box and the GET API routes never require any authentication anyway.)
- Loading branch information