Changes

Jump to navigation Jump to search
1,235 bytes added ,  15:39, 4 July 2015
Line 141: Line 141:     
Returns undef if the password could not be generated/retrieved.
 
Returns undef if the password could not be generated/retrieved.
 +
 +
=== set_secret() ===
 +
Shortcut method to create and set a password property on a record without having to extract the record first.
 +
 +
The password creation is based on an UID of 64 bits (Data::UUID). If the optional type option is passed, it will be used to create the record if it does not already exist. Otherwise, a default 'service’ type will be used to create the record.
 +
 +
The $DB is expected to be an already open esmith::DB object, so that an open DB in the caller can be re-used.  Therefore in a migrate fragment you could just use $DB.
 +
 +
esmith::util::set_secret($DB, '$key','$property'[,type=>'$type']);
 +
 +
For example in /etc/e-smith/db/configuration/migrate/90roundcube
 +
{
 +
esmith::util::set_secret($DB, ’foo’,’DbPassword’,type=>’service’);
 +
}
 +
 +
The password will be generated to the property ’DbPassword’ in the ’foo’ key.
 +
 +
If you want to change the database then you must open another esmith::DB objet
 +
{
 +
my $database = esmith::ConfigDB->open(’accounts’) or
 +
    die esmith::DB->error;
 +
esmith::util::set_secret($database, ’foo’,’DbPassword’,type=>’user’);
 +
}
 +
 +
The password is generated on an initialize-default-databases action
 +
/etc/e-smith/events/actions/initialize-default-databases
    
== HIGH LEVEL PASSWORD UTILITIES ==
 
== HIGH LEVEL PASSWORD UTILITIES ==

Navigation menu