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

fix: [SIW-1481] added magic link jwt validation #196

Merged
merged 3 commits into from
Sep 4, 2024

Conversation

silvicir
Copy link
Contributor

@silvicir silvicir commented Sep 4, 2024

List of Changes

Replaced HslJwtEnvironment and hslJwtValidate with generic JwtEnvironment and jwtValidate that contain both hsl and exchange jwt validation

Motivation and Context

This PR is about io-web token validation.
Until now only the hsl token validation was implemented, not the validation of the token obtained via the magic link

How Has This Been Tested?

Screenshots (if appropriate):

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

Copy link
Contributor

@grausof grausof left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

github-actions bot commented Sep 4, 2024

📖 Terraform Plan ('infra/resources/prod') - success

Terraform Plan
module.function_apps.module.function_app_user_autoscaler.data.azurerm_linux_function_app.this[0]: Still reading... [10s elapsed]
module.function_apps.module.function_app_user_autoscaler.data.azurerm_linux_function_app.this[0]: Still reading... [20s elapsed]

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # module.function_apps.module.function_app_user.azurerm_linux_function_app.this will be updated in-place
  ~ resource "azurerm_linux_function_app" "this" {
      ~ app_settings                                   = {
          + "ExchangeJwtIssuer"                               = "api-web.io.pagopa.it/ioweb/backend"
          + "ExchangeJwtPubKey"                               = "LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQklqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FROEFNSUlCQ2dLQ0FRRUFyNjlzOGVrRWRaSER2eTdZR1hnSEVPZUMvNEVpTVRJMDdYcUh6YjFQZi9IeDNTRW9lZkl3RXplRHcvSVZmd0FDUVMxdm5VeEJRemNPdXlGY1R3ZU9raFZ2NERVMmdLU1FIaC9kcklFZVBjZlgwcjBJYWNpeXZPVDE1TzdNWHQ2VE1FOWhTY2llM0cxT0pZRXlOZUFJVlBnUjN0S1ZTWEU5Wkk0VmthQzc4bFlrUVV4SDFaRkFUMk5ZNWNzZGo5Wi9sOTBCUHpMSzF0OFlqdDV5Z2w2UzkxQlNoMmk2QW5tZ041MUZxNXRZMTlJOTFuR09TSUpmRnVhY1hmbjZTRytHbUp3QWxSRHl3TUVXNU9mV0NYS3didDBFQkFsRWRoeitRRXdSYkg1WXVNRnR3VThhUnNobTgzRFI0VVI0dmV6cXlOOVpuQmM1cEtjYzkzTjQzMVRCTXdJREFRQUIKLS0tLS1FTkQgUFVCTElDIEtFWS0tLS0t"
          - "WEBSITE_SWAP_WARMUP_PING_PATH"                   = "/api/v1/wallet/health" -> null
          - "WEBSITE_SWAP_WARMUP_PING_STATUSES"               = "200" -> null
            # (50 unchanged elements hidden)
        }
        id                                             = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-itn-wallet-rg-01/providers/Microsoft.Web/sites/io-p-itn-wallet-user-func-01"
        name                                           = "io-p-itn-wallet-user-func-01"
        tags                                           = {
            "CostCenter"                                     = "TS310 - PAGAMENTI & SERVIZI"
            "CreatedBy"                                      = "Terraform"
            "Environment"                                    = "Prod"
            "ManagementTeam"                                 = "IO Wallet"
            "Owner"                                          = "IO"
            "Source"                                         = "https://github.com/pagopa/io-wallet/blob/main/infra/resources/prod"
        }
        # (26 unchanged attributes hidden)

      ~ site_config {
          ~ health_check_eviction_time_in_min       = 0 -> 2
            # (26 unchanged attributes hidden)

            # (1 unchanged block hidden)
        }

      ~ sticky_settings {
          ~ app_setting_names       = [
              - "APPINSIGHTS_SAMPLING_PERCENTAGE",
                "SLOT_TASK_HUBNAME",
              + "APPINSIGHTS_SAMPLING_PERCENTAGE",
                "AzureFunctionsWebHost__hostid",
            ]
            # (1 unchanged attribute hidden)
        }

        # (1 unchanged block hidden)
    }

  # module.function_apps.module.function_app_user.azurerm_linux_function_app_slot.this[0] will be updated in-place
  ~ resource "azurerm_linux_function_app_slot" "this" {
      ~ app_settings                                   = {
          ~ "APPINSIGHTS_SAMPLING_PERCENTAGE"                 = "5" -> "100"
          + "AzureFunctionsWebHost__hostid"                   = "staging"
          ~ "CosmosDbEndpoint"                                = "https://io-silvia-itn-wallet-cosno-01.documents.azure.com:443/" -> "https://io-p-itn-wallet-cosno-01.documents.azure.com:443/"
          + "ExchangeJwtIssuer"                               = "api-web.io.pagopa.it/ioweb/backend"
          + "ExchangeJwtPubKey"                               = "LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQklqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FROEFNSUlCQ2dLQ0FRRUFyNjlzOGVrRWRaSER2eTdZR1hnSEVPZUMvNEVpTVRJMDdYcUh6YjFQZi9IeDNTRW9lZkl3RXplRHcvSVZmd0FDUVMxdm5VeEJRemNPdXlGY1R3ZU9raFZ2NERVMmdLU1FIaC9kcklFZVBjZlgwcjBJYWNpeXZPVDE1TzdNWHQ2VE1FOWhTY2llM0cxT0pZRXlOZUFJVlBnUjN0S1ZTWEU5Wkk0VmthQzc4bFlrUVV4SDFaRkFUMk5ZNWNzZGo5Wi9sOTBCUHpMSzF0OFlqdDV5Z2w2UzkxQlNoMmk2QW5tZ041MUZxNXRZMTlJOTFuR09TSUpmRnVhY1hmbjZTRytHbUp3QWxSRHl3TUVXNU9mV0NYS3didDBFQkFsRWRoeitRRXdSYkg1WXVNRnR3VThhUnNobTgzRFI0VVI0dmV6cXlOOVpuQmM1cEtjYzkzTjQzMVRCTXdJREFRQUIKLS0tLS1FTkQgUFVCTElDIEtFWS0tLS0t"
          ~ "SLOT_TASK_HUBNAME"                               = "ProductionTaskHub" -> "StagingTaskHub"
          ~ "TrialSystemApiBaseURL"                           = "https://api.trial.silvia.it" -> "https://api.trial.pagopa.it"
          - "WEBSITE_SWAP_WARMUP_PING_PATH"                   = "/api/v1/wallet/health" -> null
          - "WEBSITE_SWAP_WARMUP_PING_STATUSES"               = "200" -> null
            # (46 unchanged elements hidden)
        }
        id                                             = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-itn-wallet-rg-01/providers/Microsoft.Web/sites/io-p-itn-wallet-user-func-01/slots/staging"
        name                                           = "staging"
        tags                                           = {
            "CostCenter"                                     = "TS310 - PAGAMENTI & SERVIZI"
            "CreatedBy"                                      = "Terraform"
            "Environment"                                    = "Prod"
            "ManagementTeam"                                 = "IO Wallet"
            "Owner"                                          = "IO"
            "Source"                                         = "https://github.com/pagopa/io-wallet/blob/main/infra/resources/prod"
        }
        # (22 unchanged attributes hidden)

        # (2 unchanged blocks hidden)
    }

  # module.function_apps.module.function_app_user_autoscaler.azurerm_monitor_autoscale_setting.this will be updated in-place
  ~ resource "azurerm_monitor_autoscale_setting" "this" {
        id                  = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-itn-wallet-rg-01/providers/Microsoft.Insights/autoScaleSettings/io-p-itn-wallet-user-as-01"
        name                = "io-p-itn-wallet-user-as-01"
        tags                = {
            "CostCenter"     = "TS310 - PAGAMENTI & SERVIZI"
            "CreatedBy"      = "Terraform"
            "Environment"    = "Prod"
            "ManagementTeam" = "IO Wallet"
            "Owner"          = "IO"
            "Source"         = "https://github.com/pagopa/io-wallet/blob/main/infra/resources/prod"
        }
        # (4 unchanged attributes hidden)

      ~ profile {
            name = "Default"

          - rule {
              - metric_trigger {
                  - divide_by_instance_count = false -> null
                  - metric_name              = "MemoryPercentage" -> null
                  - metric_namespace         = "microsoft.web/serverfarms" -> null
                  - metric_resource_id       = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-itn-wallet-rg-01/providers/Microsoft.Web/serverfarms/io-p-itn-wallet-user-asp-01" -> null
                  - operator                 = "GreaterThan" -> null
                  - statistic                = "Average" -> null
                  - threshold                = 70 -> null
                  - time_aggregation         = "Average" -> null
                  - time_grain               = "PT1M" -> null
                  - time_window              = "PT5M" -> null
                }
              - scale_action {
                  - cooldown  = "PT1M" -> null
                  - direction = "Increase" -> null
                  - type      = "ChangeCount" -> null
                  - value     = 1 -> null
                }
            }
          - rule {
              - metric_trigger {
                  - divide_by_instance_count = false -> null
                  - metric_name              = "MemoryPercentage" -> null
                  - metric_namespace         = "microsoft.web/serverfarms" -> null
                  - metric_resource_id       = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-itn-wallet-rg-01/providers/Microsoft.Web/serverfarms/io-p-itn-wallet-user-asp-01" -> null
                  - operator                 = "LessThan" -> null
                  - statistic                = "Average" -> null
                  - threshold                = 20 -> null
                  - time_aggregation         = "Average" -> null
                  - time_grain               = "PT1M" -> null
                  - time_window              = "PT5M" -> null
                }
              - scale_action {
                  - cooldown  = "PT5M" -> null
                  - direction = "Decrease" -> null
                  - type      = "ChangeCount" -> null
                  - value     = 1 -> null
                }
            }

            # (3 unchanged blocks hidden)
        }
    }

Plan: 0 to add, 3 to change, 0 to destroy.

─────────────────────────────────────────────────────────────────────────────

Note: You didn't use the -out option to save this plan, so Terraform can't
guarantee to take exactly these actions if you run "terraform apply" now.

@silvicir silvicir merged commit 5ed07a0 into master Sep 4, 2024
6 checks passed
@silvicir silvicir deleted the SIW-1481-ioweb-add-magic-link-jwt-validation branch September 4, 2024 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants