Class: SafeDb::Init
- Inherits:
-
Authenticate
- Object
- Controller
- Authenticate
- SafeDb::Init
- Defined in:
- lib/controller/access/init.rb
Overview
This idempotent init use case promises that a password-protected book with the given name will exist within the safe’s directory tree, along with key derivation salts, ciphertext and other paraphernalia.
After successful execution, the following state is observable
-
folder **‘~/.safedb.net/safedb-master-crypts/safedb.book.<BOOK_ID>`** exists
-
book content file **‘safedb.chapter.<CONTENT_ID>.txt`** exists
-
**‘safedb-user-configuration.ini`** links the branch and book ids
-
**‘safedb-master-index-local.ini`** has section with [<BOOK_ID>]
Within the master index file in the [<BOOK_ID>] section will be
-
the book initialiize time
-
the salts and ciphertext from the key derivation functions
-
the ID and initialization vector (iv) of the contents file
init use case pre-conditions
Warning or error messages must result unless these pre-conditions are met
-
a secret (if required) is prompted or in –password or SAFE_BOOK_PASSWORD
-
the strength of the human sourced password is adequate
-
the book name ( maybe from SAFE_BOOK_NAME ) follows convention
-
the shell must have a SAFE_TTY_TOKEN environment variable
Instance Attribute Summary
Attributes inherited from Authenticate
Instance Method Summary collapse
Methods inherited from Controller
#check_post_conditions, #check_pre_conditions, #flow, #initialize, #open_remote_backend_location, #post_validation, #pre_validation, #read_verse, #set_verse, #update_verse
Constructor Details
This class inherits a constructor from SafeDb::Controller
Instance Method Details
#execute ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/controller/access/init.rb', line 34 def execute @book_id = Identifier.derive_ergonomic_identifier( @book_name, Indices::SAFE_BOOK_ID_LENGTH ) if is_book_initialized?() print_already_initialized return end EvolveState.create_book( @book_id ) book_secret = KeyPass.password_from_shell( true ) if @password.nil? book_secret = @password unless @password.nil? master_keys = DataMap.new( Indices::MASTER_INDICES_FILEPATH ) master_keys.use( @book_id ) EvolveState.recycle_both_keys( @book_id, book_secret, master_keys, virginal_book() ) commit_msg = "safe init artifacts for newly created (#{@book_name}) book on #{TimeStamp.readable()}." GitFlow.init( Indices::MASTER_CRYPTS_FOLDER_PATH ) GitFlow.config( Indices::MASTER_CRYPTS_FOLDER_PATH, "#{ENV[ "USER" ]}@#{Socket.gethostname()}", "SafeDb User" ) GitFlow.stage( Indices::MASTER_CRYPTS_FOLDER_PATH ) GitFlow.list( Indices::MASTER_CRYPTS_FOLDER_PATH ) GitFlow.list( Indices::MASTER_CRYPTS_FOLDER_PATH, true ) GitFlow.commit( Indices::MASTER_CRYPTS_FOLDER_PATH, commit_msg ) print_success_initializing end |