Commit 04710755 authored by Andrew Gibiansky's avatar Andrew Gibiansky

Merge pull request #409 from gibiansky/check-signature-scheme

Check signature scheme, fixes #390
parents 3d167925 da7c4ca7
...@@ -70,7 +70,10 @@ data Profile = Profile { ip :: IP -- ^ The IP on which to li ...@@ -70,7 +70,10 @@ data Profile = Profile { ip :: IP -- ^ The IP on which to li
-- Convert the kernel profile to and from JSON. -- Convert the kernel profile to and from JSON.
instance FromJSON Profile where instance FromJSON Profile where
parseJSON (Object v) = parseJSON (Object v) = do
signatureScheme <- v .: "signature_scheme"
case signatureScheme of
"hmac-sha256" ->
Profile <$> v .: "ip" Profile <$> v .: "ip"
<*> v .: "transport" <*> v .: "transport"
<*> v .: "stdin_port" <*> v .: "stdin_port"
...@@ -79,6 +82,7 @@ instance FromJSON Profile where ...@@ -79,6 +82,7 @@ instance FromJSON Profile where
<*> v .: "shell_port" <*> v .: "shell_port"
<*> v .: "iopub_port" <*> v .: "iopub_port"
<*> (Text.encodeUtf8 <$> v .: "key") <*> (Text.encodeUtf8 <$> v .: "key")
sig -> error $ "Unexpected signature scheme: " ++ sig
parseJSON _ = fail "Expecting JSON object." parseJSON _ = fail "Expecting JSON object."
instance ToJSON Profile where instance ToJSON Profile where
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment