yopass 1.1.2 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8db430181db17b14ef799a4967b2309d9394c53b
4
- data.tar.gz: 1e61be3b5b13c9866cc85dbd8110b232a7b4acba
3
+ metadata.gz: 570a25ceb9e2e5bc73307fea8905cc2ffc50f8c7
4
+ data.tar.gz: 77e15af32283deca585374aef1a7bfb82d1a2581
5
5
  SHA512:
6
- metadata.gz: 4f1e92c8c9ca27e0e91b641509c02361c60d13778797fe75bc21c014b3bbff940e9ba392d8f276cb2ee2aeeef057c35fb7cc1fa8ba7250a9847f000f547f6204
7
- data.tar.gz: 67ee5fdb2509ab7d9934634c5a9ff1fabaa6f5e1f8f4216c0b7a9c68c5e36a3ca7bd2fabd9795a0cb54bfb2411724445b411d412ac35c0c48d46511d75328085
6
+ metadata.gz: bd90d1ffa4af0f7901bdd61d23137302719002b281825dff2ef35358e5af85c0de34165bcef2e229f6c8f29e5fec6f380e6f9b0d5514e6cd6b5ba3019e367842
7
+ data.tar.gz: 03421a1b0608f10bfc4de6ba191c6157e2118afcde79af1ed5536dbddcbcc849c0617d9cf0fae5756ed7a4ac87a36d2033a0d20488597c23c733c757a6ec0e02
data/.buildpacks ADDED
@@ -0,0 +1,2 @@
1
+ https://github.com/bjacobel/heroku-buildpack-libsasl.git
2
+ https://github.com/heroku/heroku-buildpack-ruby.git
data/.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
  Gem::Specification.new do |s|
3
3
  # Metadata
4
4
  s.name = 'yopass'
5
- s.version = '1.1.2'
5
+ s.version = '1.1.4'
6
6
  s.author = 'Johan Haals'
7
7
  s.email = ['jhaals@spotify.com']
8
8
  s.homepage = 'https://github.com/jhaals/yopass'
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ vendor
4
+ coverage
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Yopass changelog
2
2
 
3
+ ### 1.1.3
4
+
5
+ * display placeholder for mobile number in form.
6
+ * fixes bug where test would fail is memcached was running.
7
+
3
8
  ### 1.1.2
4
9
 
5
10
  * Typo
data/Gemfile CHANGED
@@ -5,8 +5,7 @@ gem 'encryptor', '~> 1.3.0'
5
5
  gem 'memcached', '~> 1.7.2'
6
6
  gem 'yopass', :path => '.'
7
7
 
8
- group :test do
9
- gem 'simplecov', :require => false
8
+ group :dev do
10
9
  gem 'sinatra-contrib'
11
10
  gem 'rake'
12
11
  gem 'rspec'
data/Gemfile.lock ADDED
@@ -0,0 +1,54 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ yopass (1.1.3)
5
+ encryptor (~> 1.3.0)
6
+ memcached (~> 1.7.2)
7
+ sinatra (~> 1.4.4)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ backports (3.6.0)
13
+ diff-lcs (1.2.5)
14
+ encryptor (1.3.0)
15
+ memcached (1.7.2)
16
+ multi_json (1.9.2)
17
+ rack (1.5.2)
18
+ rack-protection (1.5.2)
19
+ rack
20
+ rack-test (0.6.2)
21
+ rack (>= 1.0)
22
+ rake (10.2.2)
23
+ rspec (2.14.1)
24
+ rspec-core (~> 2.14.0)
25
+ rspec-expectations (~> 2.14.0)
26
+ rspec-mocks (~> 2.14.0)
27
+ rspec-core (2.14.8)
28
+ rspec-expectations (2.14.5)
29
+ diff-lcs (>= 1.1.3, < 2.0)
30
+ rspec-mocks (2.14.6)
31
+ sinatra (1.4.4)
32
+ rack (~> 1.4)
33
+ rack-protection (~> 1.4)
34
+ tilt (~> 1.3, >= 1.3.4)
35
+ sinatra-contrib (1.4.2)
36
+ backports (>= 2.0)
37
+ multi_json
38
+ rack-protection
39
+ rack-test
40
+ sinatra (~> 1.4.0)
41
+ tilt (~> 1.3)
42
+ tilt (1.4.1)
43
+
44
+ PLATFORMS
45
+ ruby
46
+
47
+ DEPENDENCIES
48
+ encryptor (~> 1.3.0)
49
+ memcached (~> 1.7.2)
50
+ rake
51
+ rspec
52
+ sinatra (~> 1.4.4)
53
+ sinatra-contrib
54
+ yopass!
data/Procfile ADDED
@@ -0,0 +1 @@
1
+ web: bundle exec ruby lib/yopass.rb -p $PORT
data/lib/views/index.erb CHANGED
@@ -34,7 +34,7 @@
34
34
  <div class="field">
35
35
  <label>Send decryption key over SMS (optional)</label>
36
36
  <div class="ui left labeled icon input">
37
- <input type="text" name="mobile_number" placeholder"Mobile number eg 4670222123">
37
+ <input type="text" name="mobile_number" placeholder="Mobile number eg 4670222123">
38
38
  <i class="mobile icon"></i>
39
39
  </div>
40
40
  </div>
data/lib/yopass.rb CHANGED
@@ -25,7 +25,7 @@ class Yopass < Sinatra::Base
25
25
 
26
26
  get '/' do
27
27
  # display mobile number field if send_sms is true
28
- erb :index, :locals => {:send_sms => settings.config['send_sms']}
28
+ erb :index, :locals => { :send_sms => settings.config['send_sms'] }
29
29
  end
30
30
 
31
31
  post '/' do
@@ -35,9 +35,9 @@ class Yopass < Sinatra::Base
35
35
 
36
36
  lifetime = params[:lifetime]
37
37
  # calculate lifetime in secounds
38
- lifetime_options = { '1w' => 3600*24*7,
39
- '1d' => 3600*24,
40
- '1h' => 3600,
38
+ lifetime_options = { '1w' => 3600 * 24 * 7,
39
+ '1d' => 3600 * 24,
40
+ '1h' => 3600
41
41
  }
42
42
  # Verify that user has posted a valid lifetime
43
43
  return 'Invalid lifetime' unless lifetime_options.include? lifetime
@@ -58,9 +58,9 @@ class Yopass < Sinatra::Base
58
58
  return "Can't contact memcached"
59
59
  end
60
60
 
61
- if settings.config['send_sms'] == true and !params[:mobile_number].nil?
61
+ if settings.config['send_sms'] == true && !params[:mobile_number].nil?
62
62
  # strip everything except digits
63
- mobile_number = params[:mobile_number].gsub(/[^0-9]/, "")
63
+ mobile_number = params[:mobile_number].gsub(/[^0-9]/, '')
64
64
  # load specified sms provider
65
65
  sms = SmsProvider.create(settings.config['sms::provider'],
66
66
  settings.config['sms::settings'])
@@ -75,27 +75,29 @@ class Yopass < Sinatra::Base
75
75
  end
76
76
 
77
77
  erb :secret_url, :locals => {
78
- :url => URI.join(settings.config['http_base_url'], "get?k=#{key}&p=#{password}"),
79
- :key_sent_to_mobile => false}
78
+ :url => URI.join(settings.config['http_base_url'],"get?k=#{key}&p=#{password}"),
79
+ :key_sent_to_mobile => false }
80
80
  end
81
81
 
82
82
  get '/get' do
83
83
  # No password added
84
- return erb :get_secret, :locals => {:key => params[:k]} if params[:p].nil? or params[:p].empty?
84
+ return erb :get_secret, :locals => {
85
+ :key => params[:k] } if params[:p].nil? || params[:p].empty?
85
86
 
86
87
  # Disable all caching
87
88
  headers 'Cache-Control' => 'no-cache, no-store, must-revalidate'
88
89
  headers 'Pragma' => 'no-cache'
89
90
  headers 'Expires' => '0'
91
+
90
92
  begin
91
- result = settings.cache.get params[:k]
93
+ result = settings.cache.get params[:k]
92
94
  rescue Memcached::NotFound
93
95
  return erb :'404'
94
96
  end
95
97
  content_type 'text/plain'
96
98
 
97
99
  begin
98
- result = Encryptor.decrypt(:value => result, :key => params[:p])
100
+ result = Encryptor.decrypt(:value => result, :key => params[:p])
99
101
  rescue OpenSSL::Cipher::CipherError
100
102
  return 'Invalid decryption key'
101
103
  end
@@ -5,7 +5,7 @@ class SmsProvider
5
5
  rescue LoadError => e
6
6
  raise "Unsupported provider #{provider}: #{e}"
7
7
  end
8
- class_name = provider.split("_").map {|v| v.capitalize }.join
8
+ class_name = provider.split('_').map { |v| v.capitalize }.join
9
9
  const_get(class_name).new settings
10
10
  end
11
11
  end
@@ -12,7 +12,7 @@ class Bulksms
12
12
  url = URI.join(@api_url, "?username=#{@username}&password=#{@password}" \
13
13
  "&message=#{message}&msisdn=#{to}&sender=#{@sender}")
14
14
  result = open(url).read
15
- return true if result.include? "IN_PROGRESS"
15
+ return true if result.include? 'IN_PROGRESS'
16
16
  false
17
17
  end
18
18
  end
@@ -0,0 +1,14 @@
1
+ require 'yopass/sms_provider/bulksms'
2
+ require 'spec_helper'
3
+
4
+ describe 'bulksms' do
5
+
6
+ it 'should send sms' do
7
+ sms = Bulksms.new(
8
+ 'username' => 'foobar',
9
+ 'password' => '123',
10
+ 'sender' => 'YoPass')
11
+ Bulksms.any_instance.stub(:send).and_return(true)
12
+ sms.send('467022123', 'decryption_key').should == true
13
+ end
14
+ end
@@ -0,0 +1,13 @@
1
+ require 'yopass/sms_provider'
2
+ require 'spec_helper'
3
+
4
+ describe 'sms_provider' do
5
+
6
+ it 'should fail when loading non-existing providers' do
7
+ expect { SmsProvider.create('does_not_exist', {}) }.to raise_error(RuntimeError)
8
+ end
9
+
10
+ it 'should work fine to load provider' do
11
+ SmsProvider.create('bulksms', {})
12
+ end
13
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,12 +1,8 @@
1
- require 'simplecov'
2
- SimpleCov.start do
3
- add_filter "/vendor/"
4
- end
1
+ require File.join(File.dirname(__FILE__), '../lib/yopass.rb')
2
+
5
3
  require 'sinatra'
6
4
  require 'rack/test'
7
5
 
8
- require File.join(File.dirname(__FILE__), '../lib/yopass.rb')
9
-
10
6
  set :run, false
11
7
  set :raise_errors, true
12
8
  set :logging, true
data/spec/yopass_spec.rb CHANGED
@@ -24,6 +24,7 @@ describe 'yopass' do
24
24
  end
25
25
 
26
26
  it 'should complain about not being able to connect to memcached' do
27
+ Memcached.any_instance.stub(:set).and_raise(Memcached::ServerIsMarkedDead)
27
28
  post '/', params={'lifetime' => '1h', 'secret' => "0" * 100}
28
29
  last_response.body.should match /Can't contact memcached/
29
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yopass
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johan Haals
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-07 00:00:00.000000000 Z
11
+ date: 2014-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: encryptor
@@ -59,11 +59,15 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
+ - .buildpacks
62
63
  - .gemspec
64
+ - .gitignore
63
65
  - .travis.yml
64
66
  - CHANGELOG.md
65
67
  - Gemfile
68
+ - Gemfile.lock
66
69
  - LICENSE
70
+ - Procfile
67
71
  - README.md
68
72
  - Rakefile
69
73
  - conf/config.ru
@@ -109,6 +113,8 @@ files:
109
113
  - lib/yopass.rb
110
114
  - lib/yopass/sms_provider.rb
111
115
  - lib/yopass/sms_provider/bulksms.rb
116
+ - spec/bulksms_spec.rb
117
+ - spec/sms_provder_spec.rb
112
118
  - spec/spec_helper.rb
113
119
  - spec/yopass_spec.rb
114
120
  homepage: https://github.com/jhaals/yopass
@@ -137,4 +143,7 @@ signing_key:
137
143
  specification_version: 4
138
144
  summary: Secure sharing for secrets and passwords
139
145
  test_files:
146
+ - spec/bulksms_spec.rb
147
+ - spec/sms_provder_spec.rb
140
148
  - spec/yopass_spec.rb
149
+ has_rdoc: