Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
c3b984aa
Commit
c3b984aa
authored
Mar 11, 2015
by
David Lawrence
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 1141440: OPTION response for CORS requests to REST doesn't allow X-Bugzilla headers
r=glob,a=glob
parent
74fb163c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
11 deletions
+19
-11
Constants.pm
Bugzilla/WebService/Constants.pm
+12
-0
REST.pm
Bugzilla/WebService/Server/REST.pm
+3
-1
Util.pm
Bugzilla/WebService/Util.pm
+4
-10
No files found.
Bugzilla/WebService/Constants.pm
View file @
c3b984aa
...
...
@@ -33,6 +33,8 @@ our @EXPORT = qw(
REST_CONTENT_TYPE_WHITELIST
WS_DISPATCH
API_AUTH_HEADERS
)
;
# This maps the error names in global/*-error.html.tmpl to numbers.
...
...
@@ -313,6 +315,16 @@ sub WS_DISPATCH {
return
$dispatch
;
};
# Custom HTTP headers that can be used for API authentication rather than
# passing as URL parameters. This is useful if you do not want sensitive
# information to show up in webserver log files.
use
constant
API_AUTH_HEADERS
=>
{
X_BUGZILLA_LOGIN
=>
'Bugzilla_login'
,
X_BUGZILLA_PASSWORD
=>
'Bugzilla_password'
,
X_BUGZILLA_API_KEY
=>
'Bugzilla_api_key'
,
X_BUGZILLA_TOKEN
=>
'Bugzilla_token'
,
};
1
;
=
head1
B
<
Methods
in
need
of
POD
>
...
...
Bugzilla/WebService/Server/REST.pm
View file @
c3b984aa
...
...
@@ -134,8 +134,10 @@ sub response {
{
rpc
=>
$self
,
result
=>
\
$result
,
response
=>
$response
});
# Access Control
my
@allowed_headers
=
(
qw(accept content-type origin x-requested-with)
,
map
{
tr
/A-Z_/
a
-
z
\-/
r
}
keys
API_AUTH_HEADERS
());
$response
->
header
(
"Access-Control-Allow-Origin"
,
"*"
);
$response
->
header
(
"Access-Control-Allow-Headers"
,
"origin, content-type, accept, x-requested-with"
);
$response
->
header
(
"Access-Control-Allow-Headers"
,
join
(
', '
,
@allowed_headers
)
);
# ETag support
my
$etag
=
$self
->
bz_etag
;
...
...
Bugzilla/WebService/Util.pm
View file @
c3b984aa
...
...
@@ -14,6 +14,7 @@ use warnings;
use
Bugzilla::
Flag
;
use
Bugzilla::
FlagType
;
use
Bugzilla::
Error
;
use
Bugzilla::WebService::
Constants
;
use
Storable
qw(dclone)
;
use
URI::
Escape
qw(uri_unescape)
;
...
...
@@ -261,22 +262,15 @@ sub params_to_objects {
return
\
@objects
;
}
use
constant
X_HEADERS
=>
{
X_BUGZILLA_LOGIN
=>
'Bugzilla_login'
,
X_BUGZILLA_PASSWORD
=>
'Bugzilla_password'
,
X_BUGZILLA_API_KEY
=>
'Bugzilla_api_key'
,
X_BUGZILLA_TOKEN
=>
'Bugzilla_token'
,
};
sub
fix_credentials
{
my
(
$params
,
$cgi
)
=
@_
;
# Allow user to pass in authentication details in X-Headers
# This allows callers to keep credentials out of GET request query-strings
if
(
$cgi
)
{
foreach
my
$field
(
keys
%
{
X
_HEADERS
()
})
{
next
if
exists
$params
->
{
X_HEADERS
->
{
$field
}}
||
$cgi
->
http
(
$field
)
//
''
eq
''
;
$params
->
{
X
_HEADERS
->
{
$field
}}
=
uri_unescape
(
$cgi
->
http
(
$field
));
foreach
my
$field
(
keys
%
{
API_AUTH
_HEADERS
()
})
{
next
if
exists
$params
->
{
API_AUTH_HEADERS
->
{
$field
}}
||
(
$cgi
->
http
(
$field
)
//
''
)
eq
''
;
$params
->
{
API_AUTH
_HEADERS
->
{
$field
}}
=
uri_unescape
(
$cgi
->
http
(
$field
));
}
}
...
...
Write
Preview
Markdown
is supported
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