Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
subrequests
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
subrequests
Commits
f95bc1a7
Unverified
Commit
f95bc1a7
authored
Mar 24, 2017
by
Mateu Aguiló Bosch
Browse files
Options
Downloads
Patches
Plain Diff
Fix authentication for subrequests
parent
257cb98b
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/Blueprint/RequestTree.php
+1
-0
1 addition, 0 deletions
src/Blueprint/RequestTree.php
src/Controller/FrontController.php
+1
-1
1 addition, 1 deletion
src/Controller/FrontController.php
src/Normalizer/JsonSubrequestDenormalizer.php
+19
-0
19 additions, 0 deletions
src/Normalizer/JsonSubrequestDenormalizer.php
with
21 additions
and
1 deletion
src/Blueprint/RequestTree.php
+
1
−
0
View file @
f95bc1a7
...
...
@@ -293,6 +293,7 @@ class RequestTree {
(
array
)
$request
->
server
->
getIterator
(),
$content
);
// Set the sub-request headers.
foreach
(
$request
->
headers
as
$key
=>
$val
)
{
$new_request
->
headers
->
set
(
$key
,
$val
);
}
...
...
This diff is collapsed.
Click to expand it.
src/Controller/FrontController.php
+
1
−
1
View file @
f95bc1a7
...
...
@@ -68,7 +68,7 @@ class FrontController extends ControllerBase {
// Handle the requests for the trees at this level and gather the
// responses.
$level_responses
=
array_map
(
function
(
Request
$request
)
{
return
$this
->
httpKernel
->
handle
(
$request
,
HttpKernelInterface
::
SUB
_REQUEST
);
return
$this
->
httpKernel
->
handle
(
$request
,
HttpKernelInterface
::
MASTER
_REQUEST
);
},
$requests
);
$responses
=
array_merge
(
$responses
,
...
...
This diff is collapsed.
Click to expand it.
src/Normalizer/JsonSubrequestDenormalizer.php
+
19
−
0
View file @
f95bc1a7
...
...
@@ -55,6 +55,7 @@ class JsonSubrequestDenormalizer implements DenormalizerInterface {
$request
->
setSession
(
$master_request
->
getSession
());
// Replace the headers by the ones in the subrequest.
$request
->
headers
=
new
HeaderBag
(
$data
[
'headers'
]);
$this
::
fixBasicAuth
(
$request
);
// Add the content ID to the sub-request.
$content_id
=
empty
(
$data
[
'requestId'
])
...
...
@@ -116,4 +117,22 @@ class JsonSubrequestDenormalizer implements DenormalizerInterface {
}
}
/**
* Adds the decoded username and password headers for Basic Auth.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The request to fix.
*/
protected
static
function
fixBasicAuth
(
Request
$request
)
{
// The server will not set the PHP_AUTH_USER and PHP_AUTH_PW for the
// subrequests if needed.
if
(
$request
->
headers
->
has
(
'Authorization'
))
{
$header
=
$request
->
headers
->
get
(
'Authorization'
);
if
(
strpos
(
$header
,
'Basic '
)
===
0
)
{
list
(
$user
,
$pass
)
=
explode
(
':'
,
base64_decode
(
substr
(
$header
,
6
)));
$request
->
headers
->
set
(
'PHP_AUTH_USER'
,
$user
);
$request
->
headers
->
set
(
'PHP_AUTH_PW'
,
$pass
);
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment