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

allow an Access-Control-Allow-Origin header to be set for certain oauth providers like automate #1763

Merged
merged 1 commit into from
Dec 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions components/builder-api-proxy/habitat/config/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,29 @@ http {
{{~/if}}
error_log {{pkg.svc_path}}/logs/host.error.log error;

{{~#if cfg.nginx.allow_oauth_origin}}
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '{{cfg.nginx.allow_oauth_origin}}';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
#
# Custom headers and headers various browsers *should* be OK with but aren't
#
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,skip';
#
# Tell client that this pre-flight info is valid for 20 days
#
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204;
}
try_files $uri $uri/ /index.html;
}
{{~/if}}

location = /health {
return 200;
access_log off;
Expand All @@ -168,6 +191,9 @@ http {

location /index.html {
add_header Cache-Control "private, no-cache, no-store";
{{~#if cfg.nginx.allow_oauth_origin}}
add_header 'Access-Control-Allow-Origin' '{{cfg.nginx.allow_oauth_origin}}' always;
{{~/if}}
root {{pkg.svc_config_path}};
break;
}
Expand Down