Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
open-source
MetaGer
Commits
336ad12f
Commit
336ad12f
authored
Nov 05, 2020
by
Davide Aprea
Browse files
replaced old key verification
parent
78db8739
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
app/Http/Controllers/KeyController.php
View file @
336ad12f
...
...
@@ -22,7 +22,7 @@ class KeyController extends Controller
$redirUrl
=
$request
->
input
(
'redirUrl'
,
""
);
$key
=
$request
->
input
(
'key'
,
''
);
if
(
$this
->
authorizeKey
(
$key
))
{
if
(
app
(
'App\Models\Key'
)
->
getStatus
(
))
{
# Valid Key
$host
=
$request
->
header
(
"X_Forwarded_Host"
,
""
);
if
(
empty
(
$host
))
{
...
...
@@ -45,32 +45,4 @@ class KeyController extends Controller
$url
=
LaravelLocalization
::
getLocalizedURL
(
LaravelLocalization
::
getCurrentLocale
(),
action
(
'KeyController@index'
,
[
'redirUrl'
=>
$redirUrl
]));
return
redirect
(
$url
);
}
private
function
authorizeKey
(
$key
)
{
$postdata
=
http_build_query
(
array
(
'dummy'
=>
rand
(),
));
$opts
=
array
(
'http'
=>
array
(
'method'
=>
'POST'
,
'header'
=>
'Content-type: application/x-www-form-urlencoded'
,
'content'
=>
$postdata
,
),
);
$context
=
stream_context_create
(
$opts
);
try
{
$link
=
"https://key.metager3.de/"
.
urlencode
(
$key
)
.
"/request-permission/api-access"
;
$result
=
json_decode
(
file_get_contents
(
$link
,
false
,
$context
));
if
(
$result
->
{
'api-access'
}
==
true
)
{
return
true
;
}
else
{
return
false
;
}
}
catch
(
\
ErrorException
$e
)
{
return
false
;
}
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment