Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Proxy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open-source
Proxy
Merge requests
!22
Resolve "Increase readability of Proxy URLs"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "Increase readability of Proxy URLs"
22-increase-readability-of-proxy-urls
into
master
Overview
0
Commits
18
Pipelines
0
Changes
1
Merged
Dominik Hebeler
requested to merge
22-increase-readability-of-proxy-urls
into
master
4 years ago
Overview
0
Commits
18
Pipelines
0
Changes
1
Expand
Closes
#22 (closed)
Edited
4 years ago
by
Dominik Hebeler
0
0
Merge request reports
Viewing commit
bb730920
Prev
Next
Show latest version
1 file
+
4
−
1
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
bb730920
removing integrity hash where needed
· bb730920
Dominik Hebeler
authored
4 years ago
routes/web.php
+
33
−
18
Options
@@ -23,28 +23,43 @@ Route::group(['prefix' => 'download'], function () {
Route
::
get
(
'/'
,
'DownloadController@download'
)
->
name
(
"download"
);
});
Route
::
get
(
'/'
,
function
()
{
// Route for form submissions
Route
::
get
(
'formget/{password}/{validUntil}/{url}'
,
'ProxyController@formget'
)
->
name
(
'proxy-formget'
)
->
where
(
'password'
,
'[A-Fa-f0-9]{64}'
)
->
where
(
'url'
,
'.*'
);
// Route without Proxy Header
Route
::
get
(
'p/{host?}/{path?}'
,
'ProxyController@proxy'
)
->
name
(
'proxy'
)
->
where
(
'host'
,
'[^\.]+(\.[^\.]+)+'
)
->
where
(
'path'
,
'(.*)'
);
// Route with Proxy Header
Route
::
get
(
'{host?}/{path?}'
,
'ProxyController@proxyPage'
)
->
name
(
'proxy-wrapper-page'
)
->
where
(
'host'
,
'[^\.]+(\.[^\.]+)+'
)
->
where
(
'path'
,
'(.*)'
);
Route
::
post
(
'{host?}/{path?}'
,
function
(
Request
$request
)
{
if
(
env
(
"APP_ENV"
,
""
)
!==
"production"
)
{
return
view
(
"development"
);
}
else
{
return
redirect
(
"https://metager.de"
);
$validatedData
=
$request
->
validate
([
'url'
=>
'required|url|max:255'
,
]);
$url
=
$request
->
input
(
'url'
,
'https://metager.de'
);
return
redirect
(
\App\Http\Controllers\ProxyController
::
generateProxyWrapperUrl
(
$url
));
}
else
{
abort
(
400
);
}
});
})
->
where
(
'host'
,
'[^\.]+(\.[^\.]+)+'
)
->
where
(
'path'
,
'(.*)'
)
;
Route
::
get
(
'index.css'
,
'BrowserVerification@verifyCss'
);
Route
::
post
(
'/'
,
function
(
Request
$request
)
{
$validatedData
=
$request
->
validate
([
'url'
=>
'required|url|max:255'
,
]);
$url
=
$request
->
input
(
'url'
,
'https://metager.de'
);
$
password
=
md5
(
env
(
'PROXY_PASSWORD'
)
.
$url
);
$
url
=
base64_e
n
code
(
str_rot13
(
$u
rl
));
$target
=
urlencode
(
str_replace
(
"/"
,
"<<SLASH>>"
,
$url
));
return
redirect
(
action
(
'ProxyController@proxyPage'
,
[
'password'
=>
$password
,
'url'
=>
$target
])
);
});
/**
* This is our old Proxy route
* We will keep it temporarily to help users
* migrate to the new ones and redirect to the new one.
* 15.01.2021
*/
Route
::
get
(
'{password}/{url}'
,
function
(
Request
$request
,
$password
,
$url
){
$
targetUrl
=
str_replace
(
"<<SLASH>>"
,
"/"
,
$url
);
$
targetUrl
=
str_rot13
(
base64_
d
ecode
(
$targetU
rl
));
if
(
strpos
(
$targetUrl
,
URL
::
to
(
'/'
))
===
0
)
{
return
redirect
(
$target
Url
);
}
Route
::
get
(
'{password}/{url}'
,
'ProxyController@proxyPage'
)
->
middleware
(
'throttle:60:1'
)
->
middleware
(
'checkpw'
);
return
redirect
(
\App\Http\Controllers\ProxyController
::
generateProxyWrapperUrl
(
$targetUrl
));
})
->
middleware
(
'throttle:60:1'
)
->
middleware
(
'checkpw'
);
# Route that triggers streaming of Download
Route
::
get
(
'proxy/{password}/{id}/{url}'
,
'ProxyController@proxy'
)
->
middleware
(
'checkpw:true'
);
Route
::
post
(
'proxy/{password}/{id}/{url}'
,
'ProxyController@streamFile'
)
->
middleware
(
'checkpw:true'
);
Loading