From f7b94a6d0146f40eba32256b4215101649dd7ea0 Mon Sep 17 00:00:00 2001 From: Valentin Matton Date: Fri, 29 Sep 2023 16:38:22 +0200 Subject: [PATCH] chore: allow api token auth disabling --- .github/workflows/deployment.yml | 1 + deployment/docker-compose.yml | 1 + deployment/main.tf | 6 ++++++ deployment/modules/stack_data/main.tf | 1 + deployment/modules/stack_data/variables.tf | 5 +++++ deployment/template.terraform.tfvars.json | 3 ++- 6 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 3578c0aa5..4f97b1cba 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -44,6 +44,7 @@ jobs: TF_VAR_ssh_private_key: ${{ secrets.ssh_private_key }} TF_VAR_public_hostname: ${{ vars.PUBLIC_HOSTNAME }} TF_VAR_airflow__core__fernet_key: ${{ secrets.AIRFLOW__CORE__FERNET_KEY }} + TF_VAR_api_token_enabled: ${{ vars.api_token_enabled }} ENV: ${{ vars.ENVIRONMENT }} volumes: - .:/deployment diff --git a/deployment/docker-compose.yml b/deployment/docker-compose.yml index dec94acf0..710d0642b 100644 --- a/deployment/docker-compose.yml +++ b/deployment/docker-compose.yml @@ -148,6 +148,7 @@ services: - DATABASE_URL=${AIRFLOW_CONN_PG} # TODO: create dedicated RO creds for api - SECRET_KEY=${API_SECRET_KEY} - ROOT_PATH=/api + - TOKEN_ENABLED=${API_TOKEN_ENABLED} reverse-proxy: image: traefik:v2.10 diff --git a/deployment/main.tf b/deployment/main.tf index 94821f2e7..9cd708788 100644 --- a/deployment/main.tf +++ b/deployment/main.tf @@ -82,6 +82,11 @@ variable "api_version" { type = string } +variable "api_token_enabled" { + description = "Whether to enable the api token auth or not" + type = string +} + variable "ssh_private_key" { description = "The associated public key will be deployed to the instance" type = string @@ -127,6 +132,7 @@ module "stack_data" { public_hostname = var.public_hostname airflow__core__fernet_key = var.airflow__core__fernet_key dora_api_token = var.dora_api_token + api_token_enabled = var.api_token_enabled } output "public_ip" { diff --git a/deployment/modules/stack_data/main.tf b/deployment/modules/stack_data/main.tf index cc9363ab3..bb99ed0c9 100644 --- a/deployment/modules/stack_data/main.tf +++ b/deployment/modules/stack_data/main.tf @@ -141,6 +141,7 @@ resource "null_resource" "up" { SIRENE_STOCK_UNITE_LEGALE_FILE_URL=https://www.data.gouv.fr/fr/datasets/r/825f4199-cadd-486c-ac46-a65a8ea1a047 UN_JEUNE_UNE_SOLUTION_API_URL=https://mes-aides.1jeune1solution.beta.gouv.fr/api/ PUBLIC_HOSTNAME=${var.public_hostname} + API_TOKEN_ENABLED=${var.api_token_enabled} EOT ) destination = "${local.work_dir}/deployment/.env" diff --git a/deployment/modules/stack_data/variables.tf b/deployment/modules/stack_data/variables.tf index 352ec7c2a..88d1220ad 100644 --- a/deployment/modules/stack_data/variables.tf +++ b/deployment/modules/stack_data/variables.tf @@ -104,3 +104,8 @@ variable "dora_api_token" { type = string sensitive = true } + +variable "api_token_enabled" { + description = "Whether to enable the api token auth or not" + type = string +} diff --git a/deployment/template.terraform.tfvars.json b/deployment/template.terraform.tfvars.json index daf8d7175..a24fa63d9 100644 --- a/deployment/template.terraform.tfvars.json +++ b/deployment/template.terraform.tfvars.json @@ -17,5 +17,6 @@ "ssh_private_key": null, "public_hostname": null, "airflow__core__fernet_key": null, - "dora_api_token": null + "dora_api_token": null, + "api_token_enabled": null } \ No newline at end of file