Class: KStor::Model::Secret

Inherits:
Base
  • Object
show all
Defined in:
lib/kstor/model.rb

Overview

A secret, with metadata and a value that are kept encrypted on disk.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#clean, #dirty?, #initialize, property, property?

Constructor Details

This class inherits a constructor from KStor::Model::Base

Instance Attribute Details

#ciphertextObject

Returns value of property ciphertext

Returns:

  • returns value of property ciphertext



396
# File 'lib/kstor/model.rb', line 396

property :ciphertext

#encrypted_metadataObject

Returns value of property encrypted_metadata

Returns:

  • returns value of property encrypted_metadata



400
# File 'lib/kstor/model.rb', line 400

property :encrypted_metadata

#group_idObject

Returns value of property group_id

Returns:

  • returns value of property group_id



394
# File 'lib/kstor/model.rb', line 394

property :group_id

#idObject

Returns value of property id

Returns:

  • returns value of property id



388
# File 'lib/kstor/model.rb', line 388

property :id

#meta_author_idObject

Returns value of property meta_author_id

Returns:

  • returns value of property meta_author_id



392
# File 'lib/kstor/model.rb', line 392

property :meta_author_id

#metadataObject

Returns value of property metadata

Returns:

  • returns value of property metadata



402
# File 'lib/kstor/model.rb', line 402

property :metadata, read_only: true

#plaintextObject

Returns value of property plaintext

Returns:

  • returns value of property plaintext



398
# File 'lib/kstor/model.rb', line 398

property :plaintext

#value_author_idObject

Returns value of property value_author_id

Returns:

  • returns value of property value_author_id



390
# File 'lib/kstor/model.rb', line 390

property :value_author_id

Instance Method Details

#lockObject

Forget about the decrypted value and metadata.



440
441
442
443
# File 'lib/kstor/model.rb', line 440

def lock
  self. = nil
  self.plaintext = nil
end

#to_hObject



447
448
449
450
451
# File 'lib/kstor/model.rb', line 447

def to_h
  super.except(
    *%w[ciphertext encrypted_metadata value_author_id meta_author_id]
  )
end

#unlock(author_pubk, group_privk) ⇒ Object

Decrypt secret value.

This will set the #plaintext property.

Parameters:



419
420
421
422
423
# File 'lib/kstor/model.rb', line 419

def unlock(author_pubk, group_privk)
  self.plaintext = Crypto.decrypt_secret_value(
    author_pubk, group_privk, ciphertext
  )
end

#unlock_metadata(author_pubk, group_privk) ⇒ Object

Decrypt secret metadata.

This will set the #metadata property.

Parameters:



433
434
435
436
437
# File 'lib/kstor/model.rb', line 433

def (author_pubk, group_privk)
  self. = Crypto.(
    author_pubk, group_privk, 
  )
end