Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle path after short link #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

jknphy
Copy link

@jknphy jknphy commented Jan 31, 2025

Description

Add route for handling path of this kind: <shorten-url><path> Some tools like libzypp needs support for this, for example, http://updates.suse.com returns error 404 for the / path but the /repodata/repomd.xml file is served correctly.

Example of use

Example of use: curl -vI http://127.0.0.1:5000/9og4/repodata/repomd.xml

Copy link
Contributor

@okurz okurz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like a good start. Please extend https://github.com/sqozz/schort/blob/master/tests/functional_tests.py for the new feature

schort.py Outdated Show resolved Hide resolved
@sqozz
Copy link
Owner

sqozz commented Jan 31, 2025

What other solutions did you consider? For me it feels like you're abusing a link shortening service for a shortcoming in a different piece of software (libzypp apparently needs such function to work properly?). Did you consider using a regular web server to rewrite your paths instead? E.g. in nginx you can do something like:

location = /short {
     return 301 https://a.very.long/path/to/some/subfolder/on/some/server
}

what is also missing:

@jknphy jknphy force-pushed the add-path branch 2 times, most recently from 3aefa80 to 7e2b1ea Compare February 3, 2025 08:39
@jreidinger
Copy link

Let me here explain rationale for this features:
on s390 ( mainframes ) there is a limitation how long line can be passed to kernel command line. On this command line we pass URL that leads to installation repository ( that for http has defined API structure ). We use this url shorter for testing purpose ( due to very easy creation of short url for some long testing repository ).
And here comes one shortcomming that we would like to address with this pull request. schort cannot handle subpath. Basically if we access something like http://127.0.0.1:5000/9og4it works, but if library for repository management tries to use http://127.0.0.1:5000/9og4/repodata/repomd.xml to read repository metadata schort returns 404 instead of redirection to given subpath.
So this short pull request allows in general to shorten root URL of API. And client lib can use shot URL to access even subpaths of that API ( thinking about something like REST API ).

nginx way with using directory way of location will probably work, but it miss the nice way of schort to generate short API on fly for testing versions of repository(API).

@sqozz
Copy link
Owner

sqozz commented Feb 3, 2025

I understand. My main problem with this is that schort currently does a 1 to 1 mapping, meaning 1 schort link points to 1 remote destination. This already caused problems in the past to me as my provider received abuse reports because these short links get (abused) to hide malicious content.
With this PR, you can hide even more behind a single short link (for you, this is a feature) and I fear this makes it even harder for public schort instances to exist.

Can you provide a full example of the long URL (you can replace secret stuff with random strings)? Is it really that dynamic that you need a tool with API access to create shorter paths?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants