yesod skelton and routes for pairing
yet more changes to pairing message data types
This commit is contained in:
parent
92df8250fa
commit
3bee6b3c74
5 changed files with 70 additions and 16 deletions
|
@ -12,26 +12,24 @@ import Utility.Verifiable
|
||||||
|
|
||||||
import Network.Socket (HostName)
|
import Network.Socket (HostName)
|
||||||
|
|
||||||
{- Messages sent in pairing are all verifiable using a secret that
|
{- "I'd like to pair with somebody who knows a secret." -}
|
||||||
- should be shared between the systems being paired. -}
|
data PairReq = PairReq (Verifiable PairData)
|
||||||
type PairMsg = Verifiable (PairStage, HostInfo, SshPubKey)
|
|
||||||
|
|
||||||
mkPairMsg :: Secret -> PairStage -> HostInfo -> SshPubKey -> PairMsg
|
|
||||||
mkPairMsg secret pairstage hostinfo sshkey = mkVerifiable
|
|
||||||
(pairstage, hostinfo, sshkey) secret
|
|
||||||
|
|
||||||
data PairStage
|
|
||||||
{- "I'd like to pair with somebody who knows a secret.
|
|
||||||
- Here's my ssh key, and hostinfo." -}
|
|
||||||
= PairRequest
|
|
||||||
{- "I've checked your PairRequest, and like it; I set up
|
|
||||||
- your ssh key already. Here's mine." -}
|
|
||||||
| PairAck
|
|
||||||
deriving (Eq, Read, Show)
|
deriving (Eq, Read, Show)
|
||||||
|
|
||||||
data HostInfo = HostInfo
|
{- "I've checked your PairReq, and like it.
|
||||||
|
- I set up your ssh key already. Here's mine for you to set up." -}
|
||||||
|
data PairAck = PairAck (Verifiable PairData)
|
||||||
|
deriving (Eq, Read, Show)
|
||||||
|
|
||||||
|
data PairMsg
|
||||||
|
= PairReqM PairReq
|
||||||
|
| PairAckM PairAck
|
||||||
|
deriving (Eq, Read, Show)
|
||||||
|
|
||||||
|
data PairData = PairData
|
||||||
{ hostName :: HostName
|
{ hostName :: HostName
|
||||||
, userName :: UserName
|
, userName :: UserName
|
||||||
|
, sshPubKey :: Maybe SshPubKey
|
||||||
}
|
}
|
||||||
deriving (Eq, Read, Show)
|
deriving (Eq, Read, Show)
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ import Assistant.WebApp.Notifications
|
||||||
import Assistant.WebApp.Configurators
|
import Assistant.WebApp.Configurators
|
||||||
import Assistant.WebApp.Configurators.Local
|
import Assistant.WebApp.Configurators.Local
|
||||||
import Assistant.WebApp.Configurators.Ssh
|
import Assistant.WebApp.Configurators.Ssh
|
||||||
|
import Assistant.WebApp.Configurators.Pairing
|
||||||
import Assistant.WebApp.Documentation
|
import Assistant.WebApp.Documentation
|
||||||
import Assistant.ThreadedMonad
|
import Assistant.ThreadedMonad
|
||||||
import Assistant.DaemonStatus
|
import Assistant.DaemonStatus
|
||||||
|
|
51
Assistant/WebApp/Configurators/Pairing.hs
Normal file
51
Assistant/WebApp/Configurators/Pairing.hs
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
{- git-annex assistant webapp configurator for pairing
|
||||||
|
-
|
||||||
|
- Pairing works like this:
|
||||||
|
-
|
||||||
|
- * The user optns StartPairR, which prompts them for a secret.
|
||||||
|
- * The user submits it. A PairReq is broadcast out. The secret is
|
||||||
|
- stashed away in a list of known pairing secrets.
|
||||||
|
- * On another device, it's received, and that causes its webapp to
|
||||||
|
- display an Alert.
|
||||||
|
- * The user there clicks the button, which opens FinishPairR,
|
||||||
|
- which prompts them for the same secret.
|
||||||
|
- * The secret is used to verify the PairReq. If it checks out,
|
||||||
|
- a PairAck is sent, and the other device adds the ssh key from the
|
||||||
|
- PairReq. An Alert is displayed noting that the pairing has been set up.
|
||||||
|
- * The PairAck is received back at the device that started the process.
|
||||||
|
- It's verified using the stored secret. The ssh key from the PairAck
|
||||||
|
- is added. An Alert is displayed noting that the pairing has been set
|
||||||
|
- up. Note that multiple other devices could also send PairAcks, and
|
||||||
|
- as long as they're valid, all those devices are paired with.
|
||||||
|
-
|
||||||
|
- Copyright 2012 Joey Hess <joey@kitenet.net>
|
||||||
|
-
|
||||||
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
|
-}
|
||||||
|
|
||||||
|
{-# LANGUAGE TypeFamilies, QuasiQuotes, MultiParamTypeClasses, TemplateHaskell, OverloadedStrings, RankNTypes #-}
|
||||||
|
|
||||||
|
module Assistant.WebApp.Configurators.Pairing where
|
||||||
|
|
||||||
|
import Assistant.Common
|
||||||
|
import Assistant.Pairing
|
||||||
|
import Assistant.WebApp
|
||||||
|
import Assistant.WebApp.Types
|
||||||
|
import Assistant.WebApp.SideBar
|
||||||
|
import Utility.Yesod
|
||||||
|
import Assistant.WebApp.Configurators.Local
|
||||||
|
import qualified Types.Remote as R
|
||||||
|
import qualified Remote.Rsync as Rsync
|
||||||
|
import qualified Command.InitRemote
|
||||||
|
import Logs.UUID
|
||||||
|
import Logs.Remote
|
||||||
|
|
||||||
|
import Yesod
|
||||||
|
import Data.Text (Text)
|
||||||
|
import qualified Data.Text as T
|
||||||
|
|
||||||
|
getStartPairR :: Handler RepHtml
|
||||||
|
getStartPairR = undefined
|
||||||
|
|
||||||
|
getFinishPairR :: PairReq -> Handler RepHtml
|
||||||
|
getFinishPairR = undefined
|
|
@ -19,6 +19,7 @@ import Assistant.ScanRemotes
|
||||||
import Assistant.TransferQueue
|
import Assistant.TransferQueue
|
||||||
import Assistant.TransferSlots
|
import Assistant.TransferSlots
|
||||||
import Assistant.Alert
|
import Assistant.Alert
|
||||||
|
import Assistant.Pairing
|
||||||
import Utility.NotificationBroadcaster
|
import Utility.NotificationBroadcaster
|
||||||
import Utility.WebApp
|
import Utility.WebApp
|
||||||
import Logs.Transfer
|
import Logs.Transfer
|
||||||
|
|
|
@ -11,6 +11,9 @@
|
||||||
/config/repository/add/ssh/make/git/#SshData MakeSshGitR GET
|
/config/repository/add/ssh/make/git/#SshData MakeSshGitR GET
|
||||||
/config/repository/add/ssh/make/rsync/#SshData MakeSshRsyncR GET
|
/config/repository/add/ssh/make/rsync/#SshData MakeSshRsyncR GET
|
||||||
/config/repository/add/rsync.net AddRsyncNetR GET
|
/config/repository/add/rsync.net AddRsyncNetR GET
|
||||||
|
/config/repository/pair/start StartPairR GET
|
||||||
|
/config/repository/pair/finish/#PairReq FinishPairR GET
|
||||||
|
|
||||||
/config/repository/first FirstRepositoryR GET
|
/config/repository/first FirstRepositoryR GET
|
||||||
|
|
||||||
/transfers/#NotificationId TransfersR GET
|
/transfers/#NotificationId TransfersR GET
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue