From 9c3f1ce93a4ee15735d4c073d7e11233074dfae9 Mon Sep 17 00:00:00 2001 From: Moritz Kiefer Date: Wed, 26 Jan 2022 13:11:37 +0100 Subject: [PATCH] Drop dummy token from JSON API check (#12593) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Drop dummy token from JSON API check That token is broken in a number of ways, e.g. broken ledger ids, parties that may not exist, …. When we created that there was no healthcheck endpoint on the JSON API but now that there is one, we can just use that one and it doesn’t need any token so things get a lot simpler. changelog_begin changelog_end * I promise it compiles this time changelog_begin changelog_end --- .../daml-helper/src/DA/Daml/Helper/Start.hs | 22 +------------------ 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/daml-assistant/daml-helper/src/DA/Daml/Helper/Start.hs b/daml-assistant/daml-helper/src/DA/Daml/Helper/Start.hs index b783477f73ea..3e605a9aac49 100644 --- a/daml-assistant/daml-helper/src/DA/Daml/Helper/Start.hs +++ b/daml-assistant/daml-helper/src/DA/Daml/Helper/Start.hs @@ -22,13 +22,9 @@ import Control.Concurrent import Control.Concurrent.Async import Control.Monad import Control.Monad.Extra hiding (fromMaybeM) -import qualified Data.HashMap.Strict as HashMap import Data.Maybe -import qualified Data.Map.Strict as Map import DA.PortFile import qualified Data.Text as T -import qualified Data.Text.Encoding as T -import qualified Network.HTTP.Simple as HTTP import Network.Socket.Extended (getFreePort) import System.Console.ANSI import System.FilePath @@ -36,8 +32,6 @@ import System.Process.Typed import System.IO.Extra import System.Info.Extra import Web.Browser -import qualified Web.JWT as JWT -import Data.Aeson import Options.Applicative.Extended (YesNoAuto, determineAutoM) @@ -142,22 +136,8 @@ withJsonApi (SandboxPort sandboxPort) (JsonApiPort jsonApiPort) extraArgs a = do ] ++ extraArgs withSdkJar args "json-api-logback.xml" $ \ph -> do putStrLn "Waiting for JSON API to start: " - -- The secret doesn’t matter here - let token = JWT.encodeSigned (JWT.HMACSecret "secret") mempty mempty - { JWT.unregisteredClaims = JWT.ClaimsMap $ - Map.fromList [("https://daml.com/ledger-api", Object $ HashMap.fromList - [("actAs", toJSON ["Alice" :: T.Text]), ("ledgerId", "sandbox"), ("applicationId", "foobar")])] - -- TODO https://github.com/digital-asset/daml/issues/12145 - -- Drop the ledgerId field once it becomes optional. - } - -- For now, we have a dummy authorization header here to wait for startup since we cannot get a 200 - -- response otherwise. We probably want to add some method to detect successful startup without - -- any authorization - let headers = - [ ("Authorization", "Bearer " <> T.encodeUtf8 token) - ] :: HTTP.RequestHeaders waitForHttpServer 240 (unsafeProcessHandle ph) (putStr "." *> threadDelay 500000) - ("http://localhost:" <> show jsonApiPort <> "/v1/query") headers + ("http://localhost:" <> show jsonApiPort <> "/readyz") [] a ph data JsonApiConfig = JsonApiConfig