From e12c4fc83f9a579993421e68df60766ec4d888fc Mon Sep 17 00:00:00 2001 From: Viktor Baranov Date: Tue, 25 Apr 2023 14:26:37 +0300 Subject: [PATCH] Account: derive Auth logout urls from existing envs --- .github/workflows/config.yml | 2 -- CHANGELOG.md | 1 + apps/block_scout_web/config/runtime/test.exs | 4 +--- .../lib/block_scout_web/views/layout_view.ex | 4 +++- apps/explorer/lib/explorer/account/notify.ex | 3 +-- .../explorer/test/explorer/account/notify/notify_test.exs | 3 +-- config/runtime.exs | 4 +--- deploy/testing/eth-goerli/secrets.yaml | 8 ++------ docker-compose/envs/common-blockscout.env | 2 -- docker/Makefile | 6 ------ 10 files changed, 10 insertions(+), 27 deletions(-) diff --git a/.github/workflows/config.yml b/.github/workflows/config.yml index 52ef78b022..349f762b0e 100644 --- a/.github/workflows/config.yml +++ b/.github/workflows/config.yml @@ -13,8 +13,6 @@ env: OTP_VERSION: '25.2.1' ELIXIR_VERSION: '1.14.3' ACCOUNT_AUTH0_DOMAIN: 'blockscoutcom.us.auth0.com' - ACCOUNT_AUTH0_LOGOUT_URL: 'https://blockscoutcom.us.auth0.com/v2/logout' - ACCOUNT_AUTH0_LOGOUT_RETURN_URL: 'https://blockscout.com/auth/logout' jobs: build-and-cache: diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c6f3bead8..060c792337 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ ### Chore +- [#7337](https://github.com/blockscout/blockscout/pull/7337) - Account: derive Auth0 logout urls from existing envs - [#7332](https://github.com/blockscout/blockscout/pull/7332) - Add volume for Postgres Docker containers DB - [#7328](https://github.com/blockscout/blockscout/pull/7328) - Update Docker image tag latest with release only - [#7312](https://github.com/blockscout/blockscout/pull/7312) - Add configs for Uniswap v3 transaction actions to index them on Base Goerli diff --git a/apps/block_scout_web/config/runtime/test.exs b/apps/block_scout_web/config/runtime/test.exs index cd207f042b..fcd97e783e 100644 --- a/apps/block_scout_web/config/runtime/test.exs +++ b/apps/block_scout_web/config/runtime/test.exs @@ -9,9 +9,7 @@ config :ueberauth, Ueberauth.Strategy.Auth0.OAuth, client_id: "clien_id", client_secret: "secrets" -config :ueberauth, Ueberauth, - logout_url: "example.com/logout", - logout_return_to_url: "example.com/return" +config :ueberauth, Ueberauth, logout_url: "example.com/logout" variant = Variant.get() diff --git a/apps/block_scout_web/lib/block_scout_web/views/layout_view.ex b/apps/block_scout_web/lib/block_scout_web/views/layout_view.ex index 536a012fe2..5fc7f022b6 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/layout_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/layout_view.ex @@ -5,6 +5,8 @@ defmodule BlockScoutWeb.LayoutView do alias Plug.Conn alias Poison.Parser + import BlockScoutWeb.APIDocsView, only: [blockscout_url: 1] + @default_other_networks [ %{ title: "POA", @@ -275,7 +277,7 @@ defmodule BlockScoutWeb.LayoutView do def sign_out_link do client_id = Application.get_env(:ueberauth, Ueberauth.Strategy.Auth0.OAuth)[:client_id] - return_to = Application.get_env(:ueberauth, Ueberauth)[:logout_return_to_url] + return_to = blockscout_url(true) <> "/auth/logout" logout_url = Application.get_env(:ueberauth, Ueberauth)[:logout_url] if client_id && return_to && logout_url do diff --git a/apps/explorer/lib/explorer/account/notify.ex b/apps/explorer/lib/explorer/account/notify.ex index d1c390d979..8e717f538f 100644 --- a/apps/explorer/lib/explorer/account/notify.ex +++ b/apps/explorer/lib/explorer/account/notify.ex @@ -31,8 +31,7 @@ defmodule Explorer.Account.Notify do defp check_auth0 do (Application.get_env(:ueberauth, Ueberauth.Strategy.Auth0.OAuth)[:client_id] && Application.get_env(:ueberauth, Ueberauth.Strategy.Auth0.OAuth)[:client_secret] && - Application.get_env(:ueberauth, Ueberauth)[:logout_return_to_url] && - Application.get_env(:ueberauth, Ueberauth)[:logout_url]) || + Application.get_env(:ueberauth, Ueberauth.Strategy.Auth0.OAuth)[:domain]) || raise "Auth0 not configured" end diff --git a/apps/explorer/test/explorer/account/notify/notify_test.exs b/apps/explorer/test/explorer/account/notify/notify_test.exs index 2bf64c42b7..7433374aec 100644 --- a/apps/explorer/test/explorer/account/notify/notify_test.exs +++ b/apps/explorer/test/explorer/account/notify/notify_test.exs @@ -32,8 +32,7 @@ defmodule Explorer.Account.Notify.NotifyTest do [callback_url: "callback.url"] } ], - logout_url: "logout.url", - logout_return_to_url: "return.url" + logout_url: "logout.url" ) end diff --git a/config/runtime.exs b/config/runtime.exs index 53a581305f..570d6eefd8 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -134,9 +134,7 @@ config :ueberauth, Ueberauth.Strategy.Auth0.OAuth, client_secret: System.get_env("ACCOUNT_AUTH0_CLIENT_SECRET") # Configures Ueberauth local settings -config :ueberauth, Ueberauth, - logout_url: System.get_env("ACCOUNT_AUTH0_LOGOUT_URL"), - logout_return_to_url: System.get_env("ACCOUNT_AUTH0_LOGOUT_RETURN_URL") +config :ueberauth, Ueberauth, logout_url: "https://#{System.get_env("ACCOUNT_AUTH0_DOMAIN")}/v2/logout" ######################## ### Ethereum JSONRPC ### diff --git a/deploy/testing/eth-goerli/secrets.yaml b/deploy/testing/eth-goerli/secrets.yaml index 8d046da907..4fb106ffcb 100644 --- a/deploy/testing/eth-goerli/secrets.yaml +++ b/deploy/testing/eth-goerli/secrets.yaml @@ -39,10 +39,6 @@ blockscout: _default: ENC[AES256_GCM,data:+amaFFZYsjSK5CUmJuoDioStwPO/VM1NfPwVil5wLkR2sgBKUnLOd04dn9PYdvFXQ87f0OwH13NwSppKPlx3PA==,iv:fWMO6a7xtq4/OBMIo6rIHZMpuoNPbsYKiEu7lfs10XY=,tag:YXsYNKkbwT1C6tYRpni/rA==,type:str] ACCOUNT_AUTH0_CALLBACK_URL: _default: ENC[AES256_GCM,data:6UEYDhIjZmZWa9diJwkWPzmCKRBzl+91eEOIH1uNR3qkUqhtwpF3k1o9qu54Wadw6q6Hx7ApNxiU6ZbefAjgZLY1Lzt+ZnkxOg==,iv:GXtRbFGtdK+Mp+EMXf1dINDQMIWBDNzVTFE4+Nbv9FU=,tag:215mfh63CqLl3BzRciUeig==,type:str] - ACCOUNT_AUTH0_LOGOUT_RETURN_URL: - _default: ENC[AES256_GCM,data:S0kY/XoCRJ3bYPSyuI20rY1eZtunLGjOH8+x/ggEl4+kyPKD348h4qGKVRQunbYrLcSOvJ6d7ZLmfkCdBaHTZs4=,iv:dIV/RrRjOohAe9vfbGtQT8QBVtW5gxjN3uNc1A5/spg=,tag:FYpWmrp8+TIQ4CYrYZaSUA==,type:str] - ACCOUNT_AUTH0_LOGOUT_URL: - _default: ENC[AES256_GCM,data:t4BNHWNDN6KqYdcQ7Dwod7gY7EEc0FqANm5qmosCXsyxtKAtHI4alK1/W7vFzCWo,iv:UNnPIGbs+GowAKdVK1jDjVaAlUv8RpINBOcqnhPIR1Q=,tag:dAnU1v1+EtXK/e9qgv3A4Q==,type:str] ACCOUNT_SENDGRID_API_KEY: _default: ENC[AES256_GCM,data:wTkE2ISxbX2gpObQibxl4wH7FrKtZ2eflbVaVUsImnO6kP2XRDVaKXwqaoKkzE8hztWYOpxwMcvbF7B5tjNrWgarMvFi,iv:ngGupc1U9wOu2FKPP8QacO4NmgjH84PLyf2sjwZ0yQ8=,tag:BJr7RvrrrBZMF3OpISan8g==,type:str] ACCOUNT_SENDGRID_SENDER: @@ -142,8 +138,8 @@ sops: azure_kv: [] hc_vault: [] age: [] - lastmodified: "2023-04-11T10:06:27Z" - mac: ENC[AES256_GCM,data:j8zkQv0+1dkpwCve3blZ9nZ1q9bvnw7uoaVISRDe9iFvv8q00SOvf3Ukb4+xuxGJcAW+FJKNwM++f6ftBubLVpi8hGK78xfulJFMBKhvbziYgRMwceuaX6gcrdBMfkbmo6PmUADD1EcKrmjrNxZozil01fQ0G+D1VHAiAafLifQ=,iv:Y/g6JCilPjUcPpr2CvOSFR8v4STfnvJYjGHCPXpQCcQ=,tag:2LGt74acinC6U0FPtLAhWA==,type:str] + lastmodified: "2023-04-25T10:57:00Z" + mac: ENC[AES256_GCM,data:Qo22V2i49YDjFsQxe0QRRPLHvEyn+FRRU4hw2jzwsMewvDlT8WszxLYYN6WO1HeKWfSxQyijLjnxyWd6244S7M6QRVWJnQw0x5KXznxbuDZvQzcYin6ml4HU72LpBvaDTYDRtAL6YomvHTPtwbd7pzr0Q+R42nZMmxr7Yz7v1X0=,iv:wz+UiVQ4OAoP/T/iXcg+wNgA8pnO0Ns/keHINAhLvb0=,tag:CH5iYwJASwknPi6+qYZ8Dw==,type:str] pgp: - created_at: "2022-10-10T07:37:16Z" enc: | diff --git a/docker-compose/envs/common-blockscout.env b/docker-compose/envs/common-blockscout.env index 2738c846c5..c1ca961ea4 100644 --- a/docker-compose/envs/common-blockscout.env +++ b/docker-compose/envs/common-blockscout.env @@ -179,8 +179,6 @@ DECODE_NOT_A_CONTRACT_CALLS=true # ACCOUNT_AUTH0_DOMAIN= # ACCOUNT_AUTH0_CLIENT_ID= # ACCOUNT_AUTH0_CLIENT_SECRET= -# ACCOUNT_AUTH0_LOGOUT_URL= -# ACCOUNT_AUTH0_LOGOUT_RETURN_URL= # ACCOUNT_PUBLIC_TAGS_AIRTABLE_URL= # ACCOUNT_PUBLIC_TAGS_AIRTABLE_API_KEY= # ACCOUNT_SENDGRID_API_KEY= diff --git a/docker/Makefile b/docker/Makefile index becfd2a621..b30a91689e 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -621,12 +621,6 @@ endif ifdef ACCOUNT_AUTH0_CLIENT_SECRET BLOCKSCOUT_CONTAINER_PARAMS += -e 'ACCOUNT_AUTH0_CLIENT_SECRET=$(ACCOUNT_AUTH0_CLIENT_SECRET)' endif -ifdef ACCOUNT_AUTH0_LOGOUT_RETURN_URL - BLOCKSCOUT_CONTAINER_PARAMS += -e 'ACCOUNT_AUTH0_LOGOUT_RETURN_URL=$(ACCOUNT_AUTH0_LOGOUT_RETURN_URL)' -endif -ifdef ACCOUNT_AUTH0_LOGOUT_URL - BLOCKSCOUT_CONTAINER_PARAMS += -e 'ACCOUNT_AUTH0_LOGOUT_URL=$(ACCOUNT_AUTH0_LOGOUT_URL)' -endif ifdef ACCOUNT_SENDGRID_API_KEY BLOCKSCOUT_CONTAINER_PARAMS += -e 'ACCOUNT_SENDGRID_API_KEY=$(ACCOUNT_SENDGRID_API_KEY)' endif