duritong / trocla

A password store for password creation and retrieval
Other
75 stars 18 forks source link

set method not parsing username argument correctly #46

Closed hoggle64 closed 6 years ago

hoggle64 commented 7 years ago

Hi,

as stated in the docs you should be able to provide a username when using the format pgsql. The username should be provided in the format 'username: ted'.

The class Trocla::Formats::Pgsql checks for the exsitence of options['username'] and if so, it uses it to construct the md5.

In fact options['username'] does not contain the actual user given but only the string 'username'.

You can easily verify that by adding a debug output within that class like so:

class Trocla::Formats::Pgsql < Trocla::Formats::Base
  require 'digest/md5'
  def format(plain_password,options={})
    raise "You need pass the username as an option to use this format" unless options['username']
    p "Username: " + options['username']
    "md5" + Digest::MD5.hexdigest(plain_password + options['username'])
  end
end

The result is:

>trocla set hiera/../../hieradb/nodes/postgres/ted pgsql 'username: ted'
Enter your password: xxxxxxxxxx
Repeat password: xxxxxxxxxx
"Username: username"

Because of that the trocla postgres feature cannot be used.

hoggle64 commented 7 years ago

This addresses actually the same problem: https://github.com/duritong/trocla/issues/39

duritong commented 6 years ago

Fixed with #48