From 3d88559e58089080547fc002bdc36f6ea280e4f3 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 17 Sep 2013 20:02:42 -0400 Subject: [PATCH] webapp: Show encryption information when editing a remote. --- Assistant/WebApp/Configurators/Edit.hs | 26 +++++++++- Assistant/WebApp/Configurators/Local.hs | 33 ++++-------- Assistant/WebApp/Gpg.hs | 47 ++++++++++++++++++ debian/changelog | 1 + doc/assistant/repoinfo.png | Bin 0 -> 7603 bytes .../configurators/adddrive/encrypt.hamlet | 8 +-- templates/configurators/editrepository.hamlet | 2 + 7 files changed, 84 insertions(+), 33 deletions(-) create mode 100644 Assistant/WebApp/Gpg.hs create mode 100644 doc/assistant/repoinfo.png diff --git a/Assistant/WebApp/Configurators/Edit.hs b/Assistant/WebApp/Configurators/Edit.hs index b277629aad..32d0e5ecde 100644 --- a/Assistant/WebApp/Configurators/Edit.hs +++ b/Assistant/WebApp/Configurators/Edit.hs @@ -11,6 +11,7 @@ module Assistant.WebApp.Configurators.Edit where import Assistant.WebApp.Common import Assistant.WebApp.Utility +import Assistant.WebApp.Gpg import Assistant.DaemonStatus import Assistant.MakeRemote (uniqueRemoteName) import Assistant.WebApp.Configurators.XMPP (xmppNeeded) @@ -33,6 +34,9 @@ import qualified Git.Command import qualified Git.Config import qualified Annex import Git.Remote +import Remote.Helper.Encryptable (extractCipher) +import Types.Crypto +import Utility.Gpg import qualified Data.Text as T import qualified Data.Map as M @@ -187,8 +191,9 @@ editForm new uuid = page "Edit repository" (Just Configuration) $ do redirect DashboardR _ -> do let istransfer = repoGroup curr == RepoGroupStandard TransferGroup - repoInfo <- getRepoInfo mremote . M.lookup uuid - <$> liftAnnex readRemoteLog + config <- liftAnnex $ M.lookup uuid <$> readRemoteLog + let repoInfo = getRepoInfo mremote config + let repoEncryption = getRepoEncryption mremote config $(widgetFile "configurators/editrepository") {- Makes any directory associated with the repository. -} @@ -221,3 +226,20 @@ getGitRepoInfo :: Git.Repo -> Widget getGitRepoInfo r = do let loc = Git.repoLocation r [whamlet|git repository located at #{loc}|] + +getRepoEncryption :: Maybe Remote.Remote -> Maybe Remote.RemoteConfig -> Widget +getRepoEncryption (Just _) (Just c) = case extractCipher c of + Nothing -> + [whamlet|not encrypted|] + (Just (SharedCipher _)) -> + [whamlet|encrypted: encryption key stored in git repository|] + (Just (EncryptedCipher _ _ (KeyIds { keyIds = ks }))) -> do + knownkeys <- liftIO secretKeys + [whamlet| +encrypted using gpg key: +