lockr 0.5.1 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 462008cc42bd0110c7cae997a4716b04074a3fc3
4
- data.tar.gz: 8f1723b88197dda7f18a78642aabe3777b2adc05
3
+ metadata.gz: 7587dffcce20576a1946dbda5557fe589cb11dd9
4
+ data.tar.gz: 3ee86753bf4dfd6045301b541909ab418571d80f
5
5
  SHA512:
6
- metadata.gz: 3cf9c61ab52876c0bb9260313bbb20d1b6826f9631e9c46861b842a697e82c66a652c465ca4eed5bca7ae90c076c5ec6867db9634b7c9305fdac5f7516197859
7
- data.tar.gz: c2f24dbdef030f1a6909fdb8602c8d1b36b61886c3e4cd13a75c17c5d7e9594cafded6c60e1c1849b444589c6f71af23f60f09099362c066ed96321420f90a9b
6
+ metadata.gz: ac68c79724e8eb520310eee218b23a042153b22a0c6781fef34983bf6ff58fac367dee90b45b7f40d573e2b52e680ec3c49f0643980ae2769f449a7efd294dd2
7
+ data.tar.gz: c55f59479c943aef242149ace41bd1aae174f1c6cfa738d452441a2a02fd481d9db5f75eea15823a7913001deba670190b87d10be11adc8d3c2bc56ab2dfc270
@@ -0,0 +1,68 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'lockr/http/httplockrinit'
4
+ require 'erb'
5
+ require 'clipboard'
6
+ require 'padrino-helpers'
7
+ require 'json'
8
+
9
+ include ERB::Util
10
+
11
+ init = HttpLockrInit.new()
12
+ init.start()
13
+
14
+ # now start sinatra
15
+ require 'sinatra'
16
+ require "sinatra/json"
17
+
18
+ if init.getLoadBrowser
19
+ require "browser_gui"
20
+ end
21
+
22
+ register Padrino::Helpers
23
+
24
+ set :pwdmgr, init.getPwdMgr()
25
+ # server config
26
+ set :public_dir, File.expand_path('../../resources/static', __FILE__)
27
+ set :bind, '127.0.0.1'
28
+ set :port, 32187
29
+ set :views, File.expand_path('../../resources/views', __FILE__)
30
+ enable :run
31
+
32
+ get '/' do
33
+ dir = settings.pwdmgr.list()
34
+ erb :index, :locals => { :directory => dir }
35
+ end
36
+
37
+ get '/password' do
38
+ settings.pwdmgr.copy_to_clipboard( params[:id], params[:username])
39
+ json({:message => "Password copied to clipboard. Clipboard reset in 15 seconds."})
40
+ end
41
+
42
+ post '/password' do
43
+ json = convertFormToMap( request.body.read)
44
+ newPwdstore = settings.pwdmgr.add( json['id'], json['username'], json['password'], json['url'])
45
+ dir = settings.pwdmgr.list()
46
+ json({:message => "Site "#{json['id']}/#{json['username']}" added",
47
+ :row => [
48
+ json['id'],
49
+ json['username'],
50
+ json['url']
51
+ ]})
52
+ end
53
+
54
+ patch '/password' do
55
+ json = convertFormToMap( request.body.read)
56
+ settings.pwdmgr.change( json['id'], json['username'], json['password'], json['url'])
57
+ json({:message => "Password for site "#{json['id']}/#{json['username']}" updated"})
58
+ end
59
+
60
+ delete '/password' do
61
+ json = convertFormToMap( request.body.read)
62
+ settings.pwdmgr.delete( json['id'], json['username'])
63
+ json({:message => "Password for site "#{json['id']}/#{json['username']}" deleted"})
64
+ end
65
+
66
+ def convertFormToMap( jsonForm)
67
+ Hash[JSON.parse(jsonForm).map{|el| [el['name'], el['value']]}]
68
+ end
@@ -19,8 +19,7 @@ class AddAction < BaseAction
19
19
  end
20
20
  end
21
21
 
22
- # ###TODO add url
23
- @pwdmgr.add( id, username, pwd)
22
+ @pwdmgr.add( id, username, pwd, url)
24
23
  say("Password saved for ID '<%= color('#{id}', :blue) %>' and user '<%= color('#{username}', :green) %>'")
25
24
  end
26
25
 
@@ -13,8 +13,11 @@ class HttpLockrInit
13
13
  end
14
14
 
15
15
  configfile = Configuration.new()
16
- cfg = configfile.config[:lockr]
17
- options[:vault] = File.expand_path(cfg[:vault]) if options[:vault] == 'vault.yaml'
16
+ cfg = nil
17
+ if configfile.config
18
+ cfg = configfile.config[:lockr]
19
+ end
20
+ options[:vault] = File.expand_path(cfg[:vault]) if options[:vault] == 'vault.yaml' and cfg != nil
18
21
 
19
22
  @pwdmgr = PasswordManager.new( options[:keyfile], options[:vault])
20
23
  @load_browser = options[:browser]
@@ -42,7 +42,7 @@ class PasswordManager
42
42
  end
43
43
  end
44
44
 
45
- def add( id, username, password)
45
+ def add( id, username, password, url)
46
46
  vault = decrypt_vault()
47
47
  site_dir = {}
48
48
 
@@ -51,8 +51,7 @@ class PasswordManager
51
51
  site_dir = vault[id]
52
52
  end
53
53
 
54
- # TODO add url
55
- new_store = PasswordStore.new( id, nil, username, password)
54
+ new_store = PasswordStore.new( id, url, username, password)
56
55
  site_dir[username] = new_store
57
56
  vault[id] = site_dir
58
57
 
@@ -61,10 +60,11 @@ class PasswordManager
61
60
  return new_store
62
61
  end
63
62
 
64
- def change( id, username, password)
63
+ def change( id, username, password, url)
65
64
  vault = decrypt_vault()
66
65
  site_dir = vault[id]
67
- site_dir[username].password = password
66
+ site_dir[username].password = password if ! password.nil?
67
+ site_dir[username].url = url if ! url.nil?
68
68
 
69
69
  encrypt_vault( vault)
70
70
  puts 'Changed password'
@@ -1,4 +1,4 @@
1
1
  module LockrVer
2
- VERSION = "0.5.1"
3
- DATE = "2013-11-10"
2
+ VERSION = "0.5.2"
3
+ DATE = "2013-11-19"
4
4
  end
@@ -4,7 +4,7 @@ body {
4
4
  }
5
5
 
6
6
  div.center {
7
- width: 800px;
7
+ width: 1000px;
8
8
  margin: auto;
9
9
  }
10
10
 
@@ -18,6 +18,11 @@ tr.even {
18
18
 
19
19
  table.entrytable{
20
20
  width: 100%;
21
+ table-layout:fixed;
22
+ }
23
+
24
+ table.entrytable td {
25
+ word-wrap: break-word;
21
26
  }
22
27
 
23
28
  table.entrytable .css_right {
@@ -3,9 +3,10 @@ $(document).ready(function() {
3
3
  "bJQueryUI": true,
4
4
  "bPaginate": false,
5
5
  "aoColumns": [
6
- { "sWidth": "25%" },
7
- { "sWidth": "25%" },
8
- { "sWidth": "50%" }
6
+ { "sWidth": "20%" },
7
+ { "sWidth": "20%" },
8
+ { "sWidth": "30%" },
9
+ { "sWidth": "30%" }
9
10
  ]
10
11
  });
11
12
 
@@ -15,61 +16,114 @@ $(document).ready(function() {
15
16
  $( "#dialog-addnewsite" ).dialog( "open" );
16
17
  });
17
18
 
19
+ $( '#resultbox').hide();
20
+ $( '#errorbox').hide();
21
+
22
+ $( "a#copypwd").click( function() {
23
+ var data = $( this).parents("tr.data")[0].dataset;
24
+ jQuery.ajax({
25
+ url: '/password',
26
+ data: {"id": data.id, "username": data.username},
27
+ contentType: 'application/json',
28
+ dataType: 'json'
29
+ }).done(function (response) {
30
+ $( '#errorbox').hide();
31
+ $( '#resultbox').show();
32
+ $( '#resultmsg').html( response.message);
33
+ }).fail(function () {
34
+ $( '#resultbox').hide();
35
+ $( '#errorbox').show();
36
+ $( '#errormsg').html( "Something went wrong.");
37
+ });
38
+ });
39
+
18
40
  $( "#dialog-addnewsite" ).dialog({
19
41
  autoOpen: false,
20
- height: 400,
42
+ height: 450,
21
43
  width: 400,
44
+ position: { my: "left top", at: "left bottom", of: "a#addnew" },
22
45
  modal: true,
23
46
  buttons: {
24
47
  "Save": function() {
25
- $( "form#form-add").submit();
48
+ jQuery.ajax({
49
+ url: '/password',
50
+ method: 'POST',
51
+ data: JSON.stringify($('#form-add').serializeArray()),
52
+ contentType: 'application/json',
53
+ dataType: 'json'
54
+ }).done(function (response) {
55
+ $( "#form-add").find("input[type=text], input[type=password]").val("");
56
+ $( "#dialog-addnewsite" ).dialog( "close" );
57
+ $( '#errorbox').hide();
58
+ $( '#resultbox').show();
59
+ $( '#resultmsg').html( response.message);
60
+ $( '.entrytable').dataTable().fnAddData( [
61
+ response.row[0],
62
+ response.row[1],
63
+ response.row[2],
64
+ '<a id="copypwd" class="button">Copy</a> <a id="changepwd" class="button">Change</a> <a id="deletepwd" class="button">Delete</a>'] );
65
+ $( "a.button" ).button();
66
+ }).fail(function () {
67
+ $( "#dialog-addnewsite" ).dialog( "close" );
68
+ $( '#resultbox').hide();
69
+ $( '#errorbox').show();
70
+ $( '#errormsg').html( "Something went wrong.");
71
+ });
26
72
  },
27
73
  "Cancel": function() {
28
74
  $( this ).dialog( "close" );
29
75
  }
30
- },
31
- close: function() {
32
- // clean all fields
33
- $("dialog-addnewsite input").each().val( "" ).removeClass( "ui-state-error" );
34
76
  }
35
77
  });
36
78
 
37
79
  $( "a#changepwd").click( function() {
38
- var id = $( this).siblings( ".id").get(0).value;
39
- var username = $( this).siblings( ".username").get(0).value;
40
- $("#dialog-changepwd #id").attr('value', id);
41
- $("#dialog-changepwd #id_label").html( id);
42
- $("#dialog-changepwd #username").attr('value', username);
43
- $("#dialog-changepwd #username_label").html( username);
80
+ var data = $( this).parents("tr.data")[0].dataset;
81
+ $("#dialog-changepwd #id").attr('value', data.id);
82
+ $("#dialog-changepwd #id_label").html( data.id);
83
+ $("#dialog-changepwd #username").attr('value', data.username);
84
+ $("#dialog-changepwd #username_label").html( data.username);
85
+ $("#dialog-changepwd #url").attr('value', data.url);
44
86
  $("#dialog-changepwd" ).dialog( "open" );
45
87
  });
46
88
 
47
89
  $( "#dialog-changepwd" ).dialog({
48
90
  autoOpen: false,
49
- height: 400,
91
+ height: 450,
50
92
  width: 400,
51
93
  modal: true,
52
94
  buttons: {
53
95
  "Change": function() {
54
- $( "form#form-change").submit();
96
+ jQuery.ajax({
97
+ url: '/password',
98
+ method: 'PATCH',
99
+ data: JSON.stringify($('#form-change').serializeArray()),
100
+ contentType: 'application/json',
101
+ dataType: 'json'
102
+ }).done(function (response) {
103
+ $( "#form-change").find("input[type=text], input[type=password]").val("");
104
+ $( "#dialog-changepwd" ).dialog( "close" );
105
+ $( '#errorbox').hide();
106
+ $( '#resultbox').show();
107
+ $( '#resultmsg').html( response.message);
108
+ }).fail(function () {
109
+ $( "#dialog-changepwd" ).dialog( "close" );
110
+ $( '#resultbox').hide();
111
+ $( '#errorbox').show();
112
+ $( '#errormsg').html( "Something went wrong.");
113
+ });
55
114
  },
56
115
  "Cancel": function() {
57
116
  $( this ).dialog( "close" );
58
117
  }
59
- },
60
- close: function() {
61
- // clean all fields
62
- $("dialog-changepwd input").each().val( "" ).removeClass( "ui-state-error" );
63
118
  }
64
119
  });
65
120
 
66
121
  $( "a#deletepwd").click( function() {
67
- var id = $( this).siblings( ".id").get(0).value;
68
- var username = $( this).siblings( ".username").get(0).value;
69
- $("#dialog-deletepwd #id").attr('value', id);
70
- $("#dialog-deletepwd #id_label").html( id);
71
- $("#dialog-deletepwd #username").attr('value', username);
72
- $("#dialog-deletepwd #username_label").html( username);
122
+ var data = $( this).parents("tr.data")[0].dataset;
123
+ $("#dialog-deletepwd #id").attr('value', data.id);
124
+ $("#dialog-deletepwd #id_label").html( data.id);
125
+ $("#dialog-deletepwd #username").attr('value', data.username);
126
+ $("#dialog-deletepwd #username_label").html( data.username);
73
127
  $("#dialog-deletepwd" ).dialog( "open" );
74
128
  });
75
129
 
@@ -80,15 +134,33 @@ $(document).ready(function() {
80
134
  modal: true,
81
135
  buttons: {
82
136
  "Delete": function() {
83
- $( "form#form-delete").submit();
137
+ jQuery.ajax({
138
+ url: '/password',
139
+ method: 'DELETE',
140
+ data: JSON.stringify($('#form-delete').serializeArray()),
141
+ contentType: 'application/json',
142
+ dataType: 'json'
143
+ }).done(function (response) {
144
+ var id = $('#form-delete #id').attr('value');
145
+ console.log(id);
146
+ var tr = $(".entrytable tr[data-id='" + id + "']")[0];
147
+ console.log(tr);
148
+ $( "#form-delete").find("input[type=text], input[type=password]").val("");
149
+ $( "#dialog-deletepwd" ).dialog( "close" );
150
+ $( '#errorbox').hide();
151
+ $( '#resultbox').show();
152
+ $( '#resultmsg').html( response.message);
153
+ $( '.entrytable').dataTable().fnDeleteRow( tr);
154
+ }).fail(function () {
155
+ $( "#dialog-delete" ).dialog( "close" );
156
+ $( '#resultbox').hide();
157
+ $( '#errorbox').show();
158
+ $( '#errormsg').html( "Something went wrong.");
159
+ });
84
160
  },
85
161
  "Cancel": function() {
86
162
  $( this ).dialog( "close" );
87
163
  }
88
- },
89
- close: function() {
90
- // clean all fields
91
- $("dialog-deletepwd input").each().val( "" ).removeClass( "ui-state-error" );
92
164
  }
93
165
  });
94
166
 
@@ -1,5 +1,5 @@
1
1
  <div id="dialog-addnewsite" title="Add new site" class="dialog">
2
- <form id="form-add" action="/password" method="post">
2
+ <form id="form-add">
3
3
  <fieldset>
4
4
  <label for="name">Site-ID</label>
5
5
  <input type="text" name="id" id="id" class="text ui-widget-content ui-corner-all" />
@@ -7,6 +7,8 @@
7
7
  <input type="text" name="username" id="username" class="text ui-widget-content ui-corner-all" />
8
8
  <label for="password">Password</label>
9
9
  <input type="password" name="password" id="password" class="text ui-widget-content ui-corner-all" />
10
+ <label for="url">Url</label>
11
+ <input type="text" name="url" id="url" class="text ui-widget-content ui-corner-all" />
10
12
  </fieldset>
11
13
  </form>
12
14
  </div>
@@ -1,6 +1,5 @@
1
1
  <div id="dialog-changepwd" title="Change password" class="dialog">
2
- <form id="form-change" action="/password" method="post">
3
- <input type="hidden" name="_method" value="PATCH"/>
2
+ <form id="form-change">
4
3
  <input type="hidden" name="id" id="id"/>
5
4
  <input type="hidden" name="username" id="username"/>
6
5
  <fieldset>
@@ -10,6 +9,8 @@
10
9
  <label class="labelfield ui-widget-content ui-corner-all"><span id="username_label"></span></label>
11
10
  <label for="password">Password</label>
12
11
  <input type="password" name="password" id="password" class="text ui-widget-content ui-corner-all" />
12
+ <label for="url">Url</label>
13
+ <input type="text" name="url" id="url" class="text ui-widget-content ui-corner-all" />
13
14
  </fieldset>
14
15
  </form>
15
16
  </div>
@@ -1,6 +1,5 @@
1
1
  <div id="dialog-deletepwd" title="Delete password" class="dialog">
2
- <form id="form-delete" action="/password" method="post">
3
- <input type="hidden" name="_method" value="DELETE"/>
2
+ <form id="form-delete">
4
3
  <input type="hidden" name="id" id="id"/>
5
4
  <input type="hidden" name="username" id="username"/>
6
5
  <fieldset>
@@ -1,4 +1,4 @@
1
- <tr>
1
+ <tr class="data" data-id="<%= store.id %>" data-username="<%= store.username %>" data-url="<%= store.url %>">
2
2
  <td>
3
3
  <%= store.id %>
4
4
  </td>
@@ -6,10 +6,13 @@
6
6
  <%= store.username %>
7
7
  </td>
8
8
  <td>
9
- <input type="hidden" class="id" value="<%= store.id %>"/>
10
- <input type="hidden" class="username" value="<%= store.username %>"/>
11
- <a href="/password?id=<%= u(store.id) %>&amp;username=<%= u(store.username) %>" class="button">Copy</a>
9
+ <a href="<%= store.url %>" target="_blank">
10
+ <%= store.url %>
11
+ </a>
12
+ </td>
13
+ <td>
14
+ <a id="copypwd" class="button">Copy</a>
12
15
  <a id="changepwd" class="button">Change</a>
13
- <a id="deletepwd" class="button">Delete</a>
16
+ <a id="deletepwd" class="button">Delete</a>
14
17
  </td>
15
18
  </tr>
@@ -3,6 +3,22 @@
3
3
  <div class="spacebelow">
4
4
  <a id="addnew" class="button">Add new site</a>
5
5
  </div>
6
+ <div class="ui-widget" id="resultbox">
7
+ <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
8
+ <p>
9
+ <span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
10
+ <span id="resultmsg"></span>
11
+ </p>
12
+ </div>
13
+ </div>
14
+ <div class="ui-widget" id="errorbox">
15
+ <div class="ui-state-error ui-corner-all" style="padding: 0 .7em;">
16
+ <p>
17
+ <span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span>
18
+ <span id="errormsg"></span>
19
+ </p>
20
+ </div>
21
+ </div>
6
22
  <div class="entries">
7
23
  <table class="entrytable">
8
24
  <thead>
@@ -12,6 +28,9 @@
12
28
  <th>
13
29
  Username
14
30
  </th>
31
+ <th>
32
+ Url
33
+ </th>
15
34
  <th>
16
35
  Password functions
17
36
  </th>
@@ -1,3 +1,4 @@
1
+ <!DOCTYPE html>
1
2
  <html>
2
3
  <head>
3
4
  <title> Lockr password management </title>
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lockr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marc Doerflinger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-10 00:00:00.000000000 Z
11
+ date: 2013-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: 1.6.13
19
+ version: 1.6.20
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: 1.6.13
26
+ version: 1.6.20
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ~>
67
67
  - !ruby/object:Gem::Version
68
68
  version: 1.4.4
69
+ - !ruby/object:Gem::Dependency
70
+ name: sinatra-contrib
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 1.4.1
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 1.4.1
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: clipboard
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -130,12 +144,12 @@ description: "Lockr is a password manager that features a local web interface \n
130
144
  email: info@byteblues.com
131
145
  executables:
132
146
  - lockr
133
- - httplockr.rb
147
+ - weblockr
134
148
  extensions: []
135
149
  extra_rdoc_files: []
136
150
  files:
137
- - bin/httplockr.rb
138
151
  - bin/lockr
152
+ - bin/weblockr
139
153
  - lib/lockr/action/add.rb
140
154
  - lib/lockr/action/base.rb
141
155
  - lib/lockr/action/list.rb
@@ -1,65 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'lockr/http/httplockrinit'
4
- require 'erb'
5
- require 'clipboard'
6
- require 'padrino-helpers'
7
-
8
- include ERB::Util
9
-
10
- init = HttpLockrInit.new()
11
- init.start()
12
-
13
- # now start sinatra
14
- require 'sinatra'
15
-
16
- if init.getLoadBrowser
17
- require "browser_gui"
18
- end
19
-
20
- register Padrino::Helpers
21
-
22
- set :pwdmgr, init.getPwdMgr()
23
- # server config
24
- set :public_dir, File.expand_path('../../resources/static', __FILE__)
25
- set :bind, '127.0.0.1'
26
- set :port, 32187
27
- set :views, File.expand_path('../../resources/views', __FILE__)
28
- enable :run
29
-
30
- get '/' do
31
- dir = settings.pwdmgr.list()
32
- erb :index, :locals => { :directory => dir }
33
- end
34
-
35
- get '/password' do
36
- id = params[:id]
37
- username = params[:username]
38
- settings.pwdmgr.copy_to_clipboard( id, username)
39
- redirect '/'
40
- end
41
-
42
- post '/password' do
43
- id = params[:id]
44
- username = params[:username]
45
- password = params[:password]
46
- newPwdstore = settings.pwdmgr.add( id, username, password)
47
- dir = settings.pwdmgr.list()
48
- redirect '/'
49
- end
50
-
51
- patch '/password' do
52
- id = params[:id]
53
- username = params[:username]
54
- password = params[:password]
55
- settings.pwdmgr.change( id, username, password)
56
- redirect '/'
57
- end
58
-
59
- delete '/password' do
60
- id = params[:id]
61
- username = params[:username]
62
- settings.pwdmgr.delete( id, username)
63
- redirect '/'
64
- end
65
-