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

Add cross-origin access on json interface #415

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Amygos
Copy link

@Amygos Amygos commented Jan 17, 2018

No description provided.

Add header Access-Control-Allow-Origin on json interface for enable
cross-origin HTTP requests. The presence of the header is determinate
by "alloworigin" option, if the option is present and no vaule is
specified the default vaule is "*".

See also:
https://developer.mozilla.org/docs/Web/HTTP/Headers/Access-Control-Allow-Origin
and
https://developer.mozilla.org/docs/Web/HTTP/CORS
@@ -1398,6 +1398,15 @@ int main(int argc, char **argv) {
_options.usestatusfile = STRDUP(args_info.usestatusfile_arg);
_options.uamaliasname = STRDUP(args_info.uamaliasname_arg);
_options.uamhostname = STRDUP(args_info.uamhostname_arg);

if (args_info.alloworigin_given)
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe you want the if (...) statement in thee #ifdef

Copy link
Author

@Amygos Amygos Jan 18, 2018

Choose a reason for hiding this comment

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

I leave the if (...) statement outside the #ifdef because if someone specify "alloworigin" option without json support will get a warning in syslog. I have mimic the behavior of other case like "proxylisten".

_options.alloworigin = STRDUP(args_info.alloworigin_arg);
#endif
#if(_debug_ && !defined(ENABLE_JSON))
syslog(LOG_WARNING, "JSON not implemented. build with --enable-json");
Copy link
Contributor

@xOneca xOneca Jan 18, 2018

Choose a reason for hiding this comment

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

I would add to the message which option needs JSON support (i.e. alloworigin). And maybe better error than warn?

@josealgardataborges
Copy link

Anyone cares to explain, why this PR hasn't been accepted?

@mfaroukg
Copy link

Anything wrong with this pull request?

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.

5 participants