inherit other fields
I think this is all that need to be inherited.
This commit is contained in:
parent
c3975ff3b4
commit
df5b0ffab3
4 changed files with 40 additions and 13 deletions
|
@ -131,29 +131,29 @@ remoteCipher' c gc = go $ extractCipher c
|
|||
embedCreds :: RemoteConfig -> Bool
|
||||
embedCreds c = case yesNo =<< M.lookup "embedcreds" c of
|
||||
Just v -> v
|
||||
Nothing -> isJust (M.lookup "cipherkeys" c) && isJust (M.lookup "cipher" c)
|
||||
Nothing -> isJust (M.lookup cipherkeysField c) && isJust (M.lookup cipherField c)
|
||||
|
||||
{- Gets encryption Cipher, and key encryptor. -}
|
||||
cipherKey :: RemoteConfig -> RemoteGitConfig -> Annex (Maybe (Cipher, EncKey))
|
||||
cipherKey c gc = fmap make <$> remoteCipher c gc
|
||||
where
|
||||
make ciphertext = (ciphertext, encryptKey mac ciphertext)
|
||||
mac = fromMaybe defaultMac $ M.lookup "mac" c >>= readMac
|
||||
mac = fromMaybe defaultMac $ M.lookup macField c >>= readMac
|
||||
|
||||
{- Stores an StorableCipher in a remote's configuration. -}
|
||||
storeCipher :: StorableCipher -> RemoteConfig -> RemoteConfig
|
||||
storeCipher cip = case cip of
|
||||
(SharedCipher t) -> addcipher t
|
||||
(EncryptedCipher t _ ks) -> addcipher t . storekeys ks "cipherkeys"
|
||||
(SharedPubKeyCipher t ks) -> addcipher t . storekeys ks "pubkeys"
|
||||
(EncryptedCipher t _ ks) -> addcipher t . storekeys ks cipherkeysField
|
||||
(SharedPubKeyCipher t ks) -> addcipher t . storekeys ks pubkeysField
|
||||
where
|
||||
addcipher t = M.insert "cipher" (toB64bs t)
|
||||
addcipher t = M.insert cipherField (toB64bs t)
|
||||
storekeys (KeyIds l) n = M.insert n (intercalate "," l)
|
||||
|
||||
{- Extracts an StorableCipher from a remote's configuration. -}
|
||||
extractCipher :: RemoteConfig -> Maybe StorableCipher
|
||||
extractCipher c = case (M.lookup "cipher" c,
|
||||
M.lookup "cipherkeys" c <|> M.lookup "pubkeys" c,
|
||||
extractCipher c = case (M.lookup cipherField c,
|
||||
M.lookup cipherkeysField c <|> M.lookup pubkeysField c,
|
||||
M.lookup encryptionField c) of
|
||||
(Just t, Just ks, encryption) | maybe True (== "hybrid") encryption ->
|
||||
Just $ EncryptedCipher (fromB64bs t) Hybrid (readkeys ks)
|
||||
|
@ -174,7 +174,9 @@ isEncrypted c = case M.lookup encryptionField c of
|
|||
Nothing -> hasEncryptionConfig c
|
||||
|
||||
hasEncryptionConfig :: RemoteConfig -> Bool
|
||||
hasEncryptionConfig c = M.member "cipher" c || M.member "cipherkeys" c || M.member "pubkeys" c
|
||||
hasEncryptionConfig c = M.member cipherField c
|
||||
|| M.member cipherkeysField c
|
||||
|| M.member pubkeysField c
|
||||
|
||||
describeEncryption :: RemoteConfig -> String
|
||||
describeEncryption c = case extractCipher c of
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue