Skip to content

Commit

Permalink
Merge pull request #511 from battlecode/jerrym-https
Browse files Browse the repository at this point in the history
Use https everywhere
  • Loading branch information
j-mao authored Jan 10, 2023
2 parents 5841f2b + 867c410 commit 5e71764
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 27 deletions.
4 changes: 2 additions & 2 deletions backend/siarnaq/api/compete/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def for_saturn(self):

def enqueue_options(self):
"""Return the options to be submitted to the compilation queue."""
report_url = "http://{}{}".format(
report_url = "https://{}{}".format(
settings.ALLOWED_HOSTS[0],
reverse(
"submission-report",
Expand Down Expand Up @@ -257,7 +257,7 @@ def for_saturn(self):

def enqueue_options(self):
"""Return the options to be submitted to the execution queue."""
report_url = "http://{}{}".format(
report_url = "https://{}{}".format(
settings.ALLOWED_HOSTS[0],
reverse(
"match-report",
Expand Down
2 changes: 1 addition & 1 deletion backend/siarnaq/api/episodes/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def update_autoscrim_schedule(instance, update_fields, **kwargs):
f"{parent}/jobs/"
f"{settings.GCLOUD_SCHEDULER_PREFIX}-autoscrim-{instance.name_short}"
)
url = "http://{}{}".format(
url = "https://{}{}".format(
settings.ALLOWED_HOSTS[0],
reverse("episode-autoscrim", kwargs={"pk": instance.pk}),
)
Expand Down
4 changes: 2 additions & 2 deletions deploy/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ module "production_network" {
gcp_region = var.gcp_region
gcp_zone = var.gcp_zone

use_ssl = true
https_redirect = true
subdomain = ""
cloudrun_service_name = module.production.run_service_name
sql_instance_ip = module.production.sql_instance_ip
Expand Down Expand Up @@ -134,7 +134,7 @@ module "staging_network" {
gcp_region = var.gcp_region
gcp_zone = var.gcp_zone

use_ssl = false
https_redirect = false
subdomain = "staging."
cloudrun_service_name = module.staging.run_service_name
sql_instance_ip = module.staging.sql_instance_ip
Expand Down
4 changes: 2 additions & 2 deletions deploy/network/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ module "lb" {

url_map = google_compute_url_map.this.self_link
create_url_map = false
https_redirect = var.use_ssl
https_redirect = var.https_redirect
firewall_networks = []

ssl = var.use_ssl
ssl = true
use_ssl_certificates = false
managed_ssl_certificate_domains = [for subdomain in local.subdomains : "${subdomain}battlecode.org" ]

Expand Down
4 changes: 2 additions & 2 deletions deploy/network/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ variable "subdomain" {
type = string
}

variable "use_ssl" {
description = "Whether to use and redirect to SSL."
variable "https_redirect" {
description = "Whether to redirect to SSL."
type = bool
}

Expand Down
18 changes: 0 additions & 18 deletions saturn/pkg/saturn/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,6 @@ func NewGCPTokenedReporter(
if err != nil {
return nil, fmt.Errorf("idtoken.NewClient: %v", err)
}

// Allow following redirect for POST requests
client.CheckRedirect = func(req *http.Request, via []*http.Request) error {
if len(via) >= 10 {
return fmt.Errorf("stopped after 10 redirects")
}
if via[0].GetBody == nil {
return fmt.Errorf("could not get original body")
}

var err error
req.Method = http.MethodPost
req.Body, err = via[0].GetBody()
if err != nil {
return fmt.Errorf("GetBody: %v", err)
}
return nil
}
return &GCPTokenedReporter{client, userAgent}, nil
}

Expand Down

0 comments on commit 5e71764

Please sign in to comment.