webapp: Encryption can be disabled when setting up remotes.

This commit is contained in:
Joey Hess 2012-12-04 13:28:22 -04:00
parent cf999689f7
commit c9fd389fbf
7 changed files with 31 additions and 9 deletions

View file

@ -52,6 +52,7 @@ data AWSInput = AWSInput
-- Only used for S3, not Glacier.
, storageClass :: StorageClass
, repoName :: Text
, enableEncryption :: EnableEncryption
}
data AWSCreds = AWSCreds Text Text
@ -66,6 +67,7 @@ s3InputAForm = AWSInput
<*> datacenterField AWS.S3
<*> areq (selectFieldList storageclasses) "Storage class" (Just StandardRedundancy)
<*> areq textField "Repository name" (Just "S3")
<*> enableEncryptionField
where
storageclasses :: [(Text, StorageClass)]
storageclasses =
@ -80,6 +82,7 @@ glacierInputAForm = AWSInput
<*> datacenterField AWS.Glacier
<*> pure StandardRedundancy
<*> areq textField "Repository name" (Just "glacier")
<*> enableEncryptionField
awsCredsAForm :: AForm WebApp WebApp AWSCreds
awsCredsAForm = AWSCreds
@ -112,7 +115,7 @@ getAddS3R = awsConfigurator $ do
FormSuccess input -> lift $ do
let name = T.unpack $ repoName input
makeAWSRemote S3.remote (extractCreds input) name setgroup $ M.fromList
[ ("encryption", "shared")
[ configureEncryption $ enableEncryption input
, ("type", "S3")
, ("datacenter", T.unpack $ datacenter input)
, ("storageclass", show $ storageClass input)
@ -133,7 +136,7 @@ getAddGlacierR = glacierConfigurator $ do
FormSuccess input -> lift $ do
let name = T.unpack $ repoName input
makeAWSRemote Glacier.remote (extractCreds input) name setgroup $ M.fromList
[ ("encryption", "shared")
[ configureEncryption $ enableEncryption input
, ("type", "glacier")
, ("datacenter", T.unpack $ datacenter input)
]

View file

@ -36,6 +36,7 @@ data WebDAVInput = WebDAVInput
, password :: Text
, embedCreds :: Bool
, directory :: Text
, enableEncryption :: EnableEncryption
}
toCredPair :: WebDAVInput -> CredPair
@ -47,6 +48,7 @@ boxComAForm = WebDAVInput
<*> areq passwordField "Box.com Password" Nothing
<*> areq checkBoxField "Share this account with friends?" (Just True)
<*> areq textField "Directory" (Just "annex")
<*> enableEncryptionField
webDAVCredsAForm :: AForm WebApp WebApp WebDAVInput
webDAVCredsAForm = WebDAVInput
@ -54,6 +56,7 @@ webDAVCredsAForm = WebDAVInput
<*> areq passwordField "Password" Nothing
<*> pure False
<*> pure T.empty
<*> pure NoEncryption -- not used!
getAddBoxComR :: Handler RepHtml
#ifdef WITH_WEBDAV
@ -63,7 +66,7 @@ getAddBoxComR = boxConfigurator $ do
case result of
FormSuccess input -> lift $
makeWebDavRemote "box.com" (toCredPair input) setgroup $ M.fromList
[ ("encryption", "shared")
[ configureEncryption $ enableEncryption input
, ("embedcreds", if embedCreds input then "yes" else "no")
, ("type", "webdav")
, ("url", "https://www.box.com/dav/" ++ T.unpack (directory input))