devise-argon2 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 42fc4fa5bd544b54e22ab094dbf11a72eb21480e
4
+ data.tar.gz: 6b28b034a81876e937c9177854c3778b82fd60c8
5
+ SHA512:
6
+ metadata.gz: 444b5ff3b1c5bc056e0877b07b5cd57d70d05392c3267d1e57b93a7573df522fedbcf9e618aeeda4dcb7e562ead89170e9d22370a70ca45c548da7ffc7bddf5b
7
+ data.tar.gz: 646887fb7b191cbb8ce0a7dcd4d8ee9bd3bbc06b21875aa5e4bc28719c21e31e9167443a14e1ae21dc792f84bf004898a9abdddfbf2ad41acd46bc2e029948c5
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/.travis.yml ADDED
@@ -0,0 +1,18 @@
1
+ script:
2
+ - bundle
3
+ - bundle exec rspec
4
+ rvm:
5
+ - ree
6
+ - 1.8.7
7
+ - 1.9.2
8
+ - 1.9.3
9
+ - ruby-head
10
+ - rbx-18mode
11
+ - rbx-19mode
12
+ matrix:
13
+ allow_failures:
14
+ - rvm: ruby-head
15
+ notifications:
16
+ email:
17
+ on_success: always
18
+ on_failure: always
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in gvoe_auth-client.gemspec
4
+ gemspec
5
+
6
+ gem 'rspec'
7
+ gem 'simplecov'
8
+ gem 'activesupport'
9
+ gem 'activemodel'
10
+ gem 'pry'
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016 Tamas Erdos
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,50 @@
1
+ devise-argon2 [![Build Status](https://secure.travis-ci.org/erdostom/devise-argon2.png)][Continuous Integration]
2
+ =============
3
+
4
+ **A [devise-encryptable] password encryptor that uses [argon2]**
5
+
6
+ * [Continuous Integration]
7
+
8
+ [Continuous Integration]: http://travis-ci.org/erdostom/devise-argon2 "Continuous integration @ travis-ci.org"
9
+
10
+ [argon2]: https://github.com/technion/ruby-argon2
11
+ [devise]: https://github.com/plataformatec/devise
12
+ [devise-encryptable]: https://github.com/plataformatec/devise-encryptable
13
+
14
+ ## Why use Argon2?
15
+
16
+ Argon2 won Password Hashing Competition and offers additional security compared to the default `bcrypt` by adding a memory cost. More info:
17
+
18
+ - https://github.com/P-H-C/phc-winner-argon2
19
+ - https://hynek.me/articles/storing-passwords/
20
+
21
+ ## Usage
22
+
23
+ Assuming you have [devise] (>= 2.1) and the [devise-encryptable] plugin
24
+ set up in your application, add `devise-argon2` to your `Gemfile` and `bundle`:
25
+
26
+ gem 'devise-argon2'
27
+
28
+ Then open up your [devise] configuration,`config/initializers/devise.rb` and configure your encryptor to be `argon2`:
29
+
30
+ # config/initializers/devise.rb
31
+ Devise.setup do |config|
32
+ # ..
33
+ config.encryptor = :argon2
34
+ # ...
35
+ end
36
+
37
+ It is also recommended to uncomment (or add) `config.pepper` with a random
38
+ string that will be used in addition to the per-user `password_salt` when hashing.
39
+
40
+ ## Contributing
41
+
42
+ 1. Fork it
43
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
44
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
45
+ 4. Push to the branch (`git push origin my-new-feature`)
46
+ 5. Create new Pull Request
47
+
48
+ ## Copyright
49
+
50
+ Released under MIT License.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "devise/encryptable/encryptors/argon2/version"
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "devise-argon2"
8
+ gem.version = Devise::Encryptable::Encryptors::ARGON2_VERSION
9
+ gem.authors = ["Tamas Erdos"]
10
+ gem.email = ["tamas at tamaserdos com"]
11
+ gem.description = %q{A devise-encryptable password encryptor that uses Argon2}
12
+ gem.summary = %q{A devise-encryptable password encryptor that uses Argon2}
13
+ gem.homepage = "https://github.com/erdostom/devise-argon2"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency 'devise', '>= 2.1.0'
21
+ gem.add_dependency 'devise-encryptable', '>= 0.2.0'
22
+ gem.add_dependency 'argon2', '>= 0.1.4'
23
+ end
@@ -0,0 +1,4 @@
1
+ require 'devise'
2
+ require 'devise-encryptable'
3
+ require "devise/encryptable/encryptors/argon2/version"
4
+ require "devise/encryptable/encryptors/argon2"
@@ -0,0 +1,17 @@
1
+ require 'argon2'
2
+
3
+ module Devise
4
+ module Encryptable
5
+ module Encryptors
6
+ class Argon2 < Base
7
+ def self.digest(password, stretches, salt, pepper)
8
+ ::Argon2::Password.hash("#{password}#{salt}#{pepper}")
9
+ end
10
+
11
+ def self.compare(encrypted_password, password, stretches, salt, pepper)
12
+ ::Argon2::Password.verify_password("#{password}#{salt}#{pepper}", encrypted_password)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,7 @@
1
+ module Devise
2
+ module Encryptable
3
+ module Encryptors
4
+ ARGON2_VERSION = '1.0.0'
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,31 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe Devise::Encryptable::Encryptors::Argon2 do
5
+ let(:argon2) { Devise::Encryptable::Encryptors::Argon2 }
6
+ let(:salt) { "You say you love me like salt! The simplest spice in my kingdom!" }
7
+ let(:pepper) { "I don't really want to stop the show But I thought that you might like to know That the singer's going to sing a song And he wants you all to sing along" }
8
+ let(:password) { 'Tr0ub4dor&3' }
9
+ let(:stretches) { 10 }
10
+
11
+ describe ".compare" do
12
+ let(:encrypted) { Argon2::Password.hash("#{password}#{salt}#{pepper}").to_s }
13
+
14
+ it "is true when comparing an encrypted password against given plaintext" do
15
+ expect(argon2.compare(encrypted, password, stretches, salt, pepper)).to be true
16
+ end
17
+
18
+ it "is false when comparing with wrong password" do
19
+ expect(argon2.compare(encrypted, 'hunter2', stretches, salt, pepper)).to be false
20
+ end
21
+
22
+ it "is false when comparing with correct password but wrong salt" do
23
+ expect(argon2.compare(encrypted, password, stretches, 'nacl', pepper)).to be false
24
+ end
25
+
26
+ it "is false when comparing with correct password but wrong pepper" do
27
+ expect(argon2.compare(encrypted, password, stretches, salt, 'beatles')).to be false
28
+ end
29
+ end
30
+
31
+ end
@@ -0,0 +1,9 @@
1
+ require 'rubygems'
2
+ require 'simplecov'
3
+ SimpleCov.start
4
+ require 'pry'
5
+ require 'bundler/setup'
6
+ require 'devise-argon2'
7
+
8
+ RSpec.configure do |config|
9
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: devise-argon2
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Tamas Erdos
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-01-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: devise
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 2.1.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 2.1.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: devise-encryptable
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.2.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 0.2.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: argon2
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 0.1.4
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 0.1.4
55
+ description: A devise-encryptable password encryptor that uses Argon2
56
+ email:
57
+ - tamas at tamaserdos com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - ".travis.yml"
65
+ - Gemfile
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - devise-argon2.gemspec
70
+ - lib/devise-argon2.rb
71
+ - lib/devise/encryptable/encryptors/argon2.rb
72
+ - lib/devise/encryptable/encryptors/argon2/version.rb
73
+ - spec/devise-argon2_spec.rb
74
+ - spec/spec_helper.rb
75
+ homepage: https://github.com/erdostom/devise-argon2
76
+ licenses: []
77
+ metadata: {}
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 2.4.5.1
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: A devise-encryptable password encryptor that uses Argon2
98
+ test_files:
99
+ - spec/devise-argon2_spec.rb
100
+ - spec/spec_helper.rb