Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 82f2c6c5fb | |||
| d7da4b2924 | |||
| 0267ce8792 | |||
| d0d80223f7 | |||
| 180af04891 | |||
| a048e0ad8b | |||
| d3a54f19b9 | |||
| b9d52070f1 | |||
| 6585d63385 | |||
| 258ebf29fe | |||
| 1d6fbb5f40 | |||
| 08d2827613 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,2 @@
|
||||
.stack-work/
|
||||
passman.cabal
|
||||
*~
|
||||
19
ChangeLog.md
19
ChangeLog.md
@@ -1,5 +1,24 @@
|
||||
# Changelog for passman
|
||||
|
||||
## 0.3.1.1
|
||||
|
||||
- updated documentation to on longer mention GitHub
|
||||
- updated resolver to LTS 20.19
|
||||
|
||||
## 0.3.1
|
||||
|
||||
- set maximum version of transformers package
|
||||
- allow user to specifiy a temporary master password to retrieve a password
|
||||
|
||||
## 0.3.0.2
|
||||
|
||||
- more dependency versions
|
||||
|
||||
## 0.3.0.1
|
||||
|
||||
- updated to latest stackage LTS
|
||||
- specified versions for dependencies
|
||||
|
||||
## 0.3.0
|
||||
|
||||
- updated to more recent LTS snapshot
|
||||
|
||||
13
README.md
13
README.md
@@ -1,6 +1,6 @@
|
||||
# passman
|
||||
|
||||
Copyright (C) 2018-2021 Jonathan Lamothe
|
||||
Copyright (C) 2018-2023 Jonathan Lamothe
|
||||
<jonathan@jlamothe.net>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
@@ -41,16 +41,11 @@ for instructions on installing Haskell Stack. Once you have done
|
||||
this, you can simply enter the command `stack install passman` in the
|
||||
terminal to install passman.
|
||||
|
||||
## GitHub
|
||||
## Codeberg
|
||||
|
||||
The most recent version of passman can be found on GitHub at
|
||||
<https://github.com/jlamothe/passman>.
|
||||
The most recent version of passman can be found on Codeberg at
|
||||
<https://codeberg.org/jlamothe/passman>.
|
||||
|
||||
## Pull Requests
|
||||
|
||||
Pull requests are welcome, but should be made to the `dev` branch.
|
||||
|
||||
## Donations
|
||||
|
||||
Bitcoin donations are accepted (but not required) at:
|
||||
18hqEsXCinyauDp6smPUEVuscjDdasTKvr
|
||||
|
||||
@@ -26,7 +26,7 @@ module Types (Status (Status), gen, dbPath, masterPass, database) where
|
||||
|
||||
import Lens.Micro (set, (^.))
|
||||
import Lens.Micro.TH (makeLenses)
|
||||
import System.Random (RandomGen (next, split), StdGen)
|
||||
import System.Random (RandomGen (genWord64, split), StdGen)
|
||||
|
||||
import Password
|
||||
|
||||
@@ -40,8 +40,8 @@ data Status = Status
|
||||
makeLenses ''Status
|
||||
|
||||
instance RandomGen Status where
|
||||
next s = (x, s') where
|
||||
(x, g') = next g
|
||||
genWord64 s = (x, s') where
|
||||
(x, g') = genWord64 g
|
||||
s' = set gen g' s
|
||||
g = s^.gen
|
||||
split s = (s1, s2) where
|
||||
|
||||
38
app/UI.hs
38
app/UI.hs
@@ -27,7 +27,7 @@ module UI (getMasterPass, mainMenu) where
|
||||
import Control.Monad (when)
|
||||
import Control.Monad.Trans.Class (lift)
|
||||
import qualified Control.Monad.Trans.State as S
|
||||
import Lens.Micro (over, set, (^.))
|
||||
import Lens.Micro (over, set, (^.), (.~))
|
||||
import Lens.Micro.Extras (view)
|
||||
import System.Console.HCL
|
||||
( Request
|
||||
@@ -161,11 +161,12 @@ selectServ xs = menu "Select Service" $
|
||||
|
||||
servMenu :: String -> S.StateT Status IO ()
|
||||
servMenu x = menu x
|
||||
[ ( "show password", showPass x >> servMenu x )
|
||||
, ( "edit password", editPassMenu x )
|
||||
, ( "remove service", removeServ x )
|
||||
, ( "rename service", renameServ x )
|
||||
, ( "back", mainMenu )
|
||||
[ ( "show password", showPass x >> servMenu x )
|
||||
, ( "show alternate password", showAltPass x )
|
||||
, ( "edit password", editPassMenu x )
|
||||
, ( "remove service", removeServ x )
|
||||
, ( "rename service", renameServ x )
|
||||
, ( "back", mainMenu )
|
||||
]
|
||||
|
||||
editPassMenu :: String -> S.StateT Status IO ()
|
||||
@@ -225,15 +226,24 @@ doEditPolicy x = withService x mainMenu $ \d -> do
|
||||
editPassMenu x
|
||||
|
||||
showPass :: String -> S.StateT Status IO ()
|
||||
showPass x = do
|
||||
showPass x = withService x
|
||||
(lift $ putStrLn "The service could not be found in the database.") $
|
||||
\d -> do
|
||||
lift $ putStrLn ""
|
||||
mp <- S.gets $ view masterPass
|
||||
lift $ putStrLn $ case pwGenerate mp d of
|
||||
Nothing -> "The password data were not valid."
|
||||
Just pw -> "password for " ++ x ++ ": " ++ pw
|
||||
|
||||
showAltPass :: String -> S.StateT Status IO ()
|
||||
showAltPass srv = do
|
||||
lift $ putStrLn ""
|
||||
withService x
|
||||
(lift $ putStrLn "The service could not be found in the database.") $
|
||||
\d -> do
|
||||
mp <- S.gets $ view masterPass
|
||||
lift $ putStrLn $ case pwGenerate mp d of
|
||||
Nothing -> "The password data were not valid."
|
||||
Just pw -> "password for " ++ x ++ ": " ++ pw
|
||||
old <- S.gets $ view masterPass
|
||||
Just new <- lift $ runRequest $ required $ prompt "alternate master password: " reqPassword
|
||||
S.modify $ masterPass .~ new
|
||||
showPass srv
|
||||
S.modify $ masterPass .~ old
|
||||
servMenu srv
|
||||
|
||||
-- TODO: refactor this monstrosity
|
||||
editPolicy :: PWPolicy -> Request PWPolicy
|
||||
|
||||
29
package.yaml
29
package.yaml
@@ -1,10 +1,11 @@
|
||||
name: passman
|
||||
version: 0.3.0
|
||||
github: "jlamothe/passman"
|
||||
license: LGPL-3
|
||||
version: 0.3.1.1
|
||||
license: LGPL-3.0-or-later
|
||||
author: "Jonathan Lamothe"
|
||||
maintainer: "jonathan@jlamothe.net"
|
||||
copyright: "(C) 2018-2021 Jonathan Lamothe"
|
||||
copyright: "(C) 2018-2023 Jonathan Lamothe"
|
||||
homepage: https://codeberg.org/jlamothe/passman
|
||||
bug-reports: https://codeberg.org/jlamothe/passman/issues
|
||||
|
||||
extra-source-files:
|
||||
- README.md
|
||||
@@ -17,16 +18,16 @@ category: Security
|
||||
# To avoid duplicated efforts in documentation and dealing with the
|
||||
# complications of embedding Haddock markup inside cabal files, it is
|
||||
# common to point users to the README.md file.
|
||||
description: Please see the README on GitHub at <https://github.com/jlamothe/passman#readme>
|
||||
description: a simple password manager - see README.md for details
|
||||
|
||||
dependencies:
|
||||
- base >= 4.7 && < 5
|
||||
- aeson
|
||||
- bytestring
|
||||
- containers
|
||||
- aeson >= 2.0.3.0 && < 2.1
|
||||
- bytestring >= 0.11.4.0 && < 0.12
|
||||
- containers >= 0.6.2.1 && < 0.7
|
||||
- microlens >= 0.4.11.2 && < 0.5
|
||||
- microlens-th >= 0.4.3.6 && < 0.5
|
||||
- random
|
||||
- random >=1.2.1.1 && < 1.3
|
||||
|
||||
ghc-options:
|
||||
- -Wall
|
||||
@@ -34,10 +35,10 @@ ghc-options:
|
||||
library:
|
||||
source-dirs: src
|
||||
dependencies:
|
||||
- base16-bytestring
|
||||
- base64-bytestring
|
||||
- SHA
|
||||
- text
|
||||
- base16-bytestring >= 1.0.2.0 && < 1.1
|
||||
- base64-bytestring >= 1.2.1.0 && < 1.3
|
||||
- SHA >= 1.6.4.4 && < 1.7
|
||||
- text >= 1.2.4.1 && < 1.3
|
||||
|
||||
executables:
|
||||
passman:
|
||||
@@ -51,7 +52,7 @@ executables:
|
||||
- passman
|
||||
- easy-file >= 0.2.2 && < 0.3
|
||||
- HCL >= 1.8 && < 1.9
|
||||
- transformers
|
||||
- transformers >= 0.5.6.2 && < 0.6
|
||||
|
||||
tests:
|
||||
passman-test:
|
||||
|
||||
110
passman.cabal
Normal file
110
passman.cabal
Normal file
@@ -0,0 +1,110 @@
|
||||
cabal-version: 2.2
|
||||
|
||||
-- This file has been generated from package.yaml by hpack version 0.35.1.
|
||||
--
|
||||
-- see: https://github.com/sol/hpack
|
||||
--
|
||||
-- hash: da6c3020622e5c4c06814752b3f3334e52925005f8b3be9516efb9fd1976af9c
|
||||
|
||||
name: passman
|
||||
version: 0.3.1.1
|
||||
synopsis: a simple password manager
|
||||
description: a simple password manager - see README.md for details
|
||||
category: Security
|
||||
homepage: https://codeberg.org/jlamothe/passman
|
||||
bug-reports: https://codeberg.org/jlamothe/passman/issues
|
||||
author: Jonathan Lamothe
|
||||
maintainer: jonathan@jlamothe.net
|
||||
copyright: (C) 2018-2023 Jonathan Lamothe
|
||||
license: LGPL-3.0-or-later
|
||||
license-file: LICENSE
|
||||
build-type: Simple
|
||||
extra-source-files:
|
||||
README.md
|
||||
ChangeLog.md
|
||||
|
||||
library
|
||||
exposed-modules:
|
||||
Password
|
||||
other-modules:
|
||||
Paths_passman
|
||||
autogen-modules:
|
||||
Paths_passman
|
||||
hs-source-dirs:
|
||||
src
|
||||
ghc-options: -Wall
|
||||
build-depends:
|
||||
SHA >=1.6.4.4 && <1.7
|
||||
, aeson >=2.0.3.0 && <2.1
|
||||
, base >=4.7 && <5
|
||||
, base16-bytestring >=1.0.2.0 && <1.1
|
||||
, base64-bytestring >=1.2.1.0 && <1.3
|
||||
, bytestring >=0.11.4.0 && <0.12
|
||||
, containers >=0.6.2.1 && <0.7
|
||||
, microlens >=0.4.11.2 && <0.5
|
||||
, microlens-th >=0.4.3.6 && <0.5
|
||||
, random >=1.2.1.1 && <1.3
|
||||
, text >=1.2.4.1 && <1.3
|
||||
default-language: Haskell2010
|
||||
|
||||
executable passman
|
||||
main-is: Main.hs
|
||||
other-modules:
|
||||
Types
|
||||
UI
|
||||
Util
|
||||
Paths_passman
|
||||
autogen-modules:
|
||||
Paths_passman
|
||||
hs-source-dirs:
|
||||
app
|
||||
ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N
|
||||
build-depends:
|
||||
HCL ==1.8.*
|
||||
, aeson >=2.0.3.0 && <2.1
|
||||
, base >=4.7 && <5
|
||||
, bytestring >=0.11.4.0 && <0.12
|
||||
, containers >=0.6.2.1 && <0.7
|
||||
, easy-file >=0.2.2 && <0.3
|
||||
, microlens >=0.4.11.2 && <0.5
|
||||
, microlens-th >=0.4.3.6 && <0.5
|
||||
, passman
|
||||
, random >=1.2.1.1 && <1.3
|
||||
, transformers >=0.5.6.2 && <0.6
|
||||
default-language: Haskell2010
|
||||
|
||||
test-suite passman-test
|
||||
type: exitcode-stdio-1.0
|
||||
main-is: Spec.hs
|
||||
other-modules:
|
||||
Spec.JSON
|
||||
Spec.NewPWData
|
||||
Spec.NewPWDatabase
|
||||
Spec.NewPWPolicy
|
||||
Spec.NewPWSalt
|
||||
Spec.PWGenerate
|
||||
Spec.PWGetService
|
||||
Spec.PWHasService
|
||||
Spec.PWRemoveService
|
||||
Spec.PWSearch
|
||||
Spec.PWSetService
|
||||
Spec.ValidatePWData
|
||||
Spec.ValidatePWDatabase
|
||||
Spec.ValidatePWPolicy
|
||||
Paths_passman
|
||||
autogen-modules:
|
||||
Paths_passman
|
||||
hs-source-dirs:
|
||||
test
|
||||
ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N
|
||||
build-depends:
|
||||
HUnit
|
||||
, aeson >=2.0.3.0 && <2.1
|
||||
, base >=4.7 && <5
|
||||
, bytestring >=0.11.4.0 && <0.12
|
||||
, containers >=0.6.2.1 && <0.7
|
||||
, microlens >=0.4.11.2 && <0.5
|
||||
, microlens-th >=0.4.3.6 && <0.5
|
||||
, passman
|
||||
, random >=1.2.1.1 && <1.3
|
||||
default-language: Haskell2010
|
||||
@@ -63,6 +63,7 @@ import qualified Data.ByteString.Base16.Lazy as B16
|
||||
import qualified Data.ByteString.Base64.Lazy as B64
|
||||
import Data.Char (isUpper, isLower, isDigit, isAlphaNum, toLower)
|
||||
import Data.Digest.Pure.SHA
|
||||
import Data.Either (fromRight)
|
||||
import qualified Data.Map as M
|
||||
import Data.Maybe (fromMaybe)
|
||||
import qualified Data.Text as T
|
||||
@@ -341,7 +342,7 @@ mkSeed :: String -> PWData ->B.ByteString
|
||||
mkSeed pw d = toUTF8 pw `B.append` (d^.pwSalt.to runPWSalt)
|
||||
|
||||
mkHash :: B.ByteString -> B.ByteString
|
||||
mkHash = fst . B16.decode . toUTF8 . show . sha256
|
||||
mkHash = fromRight "" . B16.decode . toUTF8 . show . sha256
|
||||
|
||||
nextPolicy :: Char -> PWPolicy -> PWPolicy
|
||||
nextPolicy x p = over pwLength pred $
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#
|
||||
# resolver: ./custom-snapshot.yaml
|
||||
# resolver: https://example.com/snapshots/2018-01-01.yaml
|
||||
resolver: lts-16.27
|
||||
resolver: lts-20.19
|
||||
|
||||
# User packages to be built.
|
||||
# Various formats can be used as shown in the example below.
|
||||
|
||||
@@ -7,13 +7,13 @@ packages:
|
||||
- completed:
|
||||
hackage: HCL-1.8@sha256:39ec0da0cd6157f20c395e1b0df474df45efb0088afdaab20bb9dfb3662baf7c,1726
|
||||
pantry-tree:
|
||||
size: 1223
|
||||
sha256: 5c93c5184dc378de5ecf235aa1a60dc24163ab7e0efad19c8f3bbc94354cf2b8
|
||||
size: 1223
|
||||
original:
|
||||
hackage: HCL-1.8@sha256:39ec0da0cd6157f20c395e1b0df474df45efb0088afdaab20bb9dfb3662baf7c,1726
|
||||
snapshots:
|
||||
- completed:
|
||||
size: 533252
|
||||
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/16/27.yaml
|
||||
sha256: c2aaae52beeacf6a5727c1010f50e89d03869abfab6d2c2658ade9da8ed50c73
|
||||
original: lts-16.27
|
||||
sha256: 42f77c84b34f68c30c2cd0bf8c349f617a0f428264362426290847a6a2019b64
|
||||
size: 649618
|
||||
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/20/19.yaml
|
||||
original: lts-20.19
|
||||
|
||||
Reference in New Issue
Block a user