seraph 0.0.2 → 0.0.3

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: 583f6cf6fa11ad1334eb9d55301e63b7eb53b080
4
- data.tar.gz: 4ba819366691c555e82ac8b67fd7957573e8c8cb
3
+ metadata.gz: c38bec486a10c2137abb51d2960a95863594eb71
4
+ data.tar.gz: ea8f366ee742c81b9bf61f0b90a2da7e0b60389a
5
5
  SHA512:
6
- metadata.gz: a5fa9e929257ad04d0bb75e963cb77d2085d2b5b02368fb9aedeff77deda4c412d9ead96a67fec3bc06e0cc92690c9856a74a6ce786ad5ca63dfbff84df79bba
7
- data.tar.gz: 73e9248e3efd0810ed71b84f08cbc24c93eb070d7be0cbb2084259bee9675f2c17da21b98e7a422f13790049d5aab3bf92817ba50f96e9601b35c66c5ec605a9
6
+ metadata.gz: 1e5d554f25769f57f42cc5d9e916ae00cb2f85cc15b229884f25e3a57d41f7c9c485efdb24682c8671ff78abb14b20367f8bdac9686ca1adc6a5db34d90fa709
7
+ data.tar.gz: 82c075c768a468fe62b7714e13ec9ca5714884aee418b064fb8676a4f766eec5e0df5fd018a5946ea108c67e6d90862aa701800d5d2786b465a2a2e57f1e01c3
data/README.md CHANGED
@@ -1,13 +1,12 @@
1
1
  # seraph
2
- [![Build Status](https://secure.travis-ci.org//seraph.svg?branch=master)](https://travis-ci.org//seraph)
2
+ [![Build Status](https://travis-ci.org/Szeliga/seraph.svg?branch=master)](https://travis-ci.org/Szeliga/seraph)
3
+
4
+ A simple framework-agnostic library for authentication. seraph provides an API for implementing User authentication inside your app. It doesn't make any assumptions about your setup, so you do not have to have a `User` class that inherits from `ActiveRecord::Base`.
3
5
 
4
- * [Homepage](https://rubygems.org/gems/seraph)
5
- * [Documentation](http://rubydoc.info/gems/seraph/frames)
6
- * [Email](mailto:szymon.szeliga at netguru.co)
7
6
 
8
7
  ## Installation
9
8
 
10
- Type
9
+ Enter in your terminal
11
10
  ```
12
11
  gem install seraph
13
12
  ```
@@ -15,11 +14,7 @@ or put
15
14
  ```
16
15
  gem 'seraph'
17
16
  ```
18
- inside your Gemfile
19
-
20
- ## Description
21
-
22
- A simple framework-agnostic library for authentication. seraph provides an API for implementing User authentication inside your app. It doesn't make any assumptions about your setup, so you do not have to have a `User` class that inherits from `ActiveRecord::Base`.
17
+ inside your `Gemfile`
23
18
 
24
19
  ### What do you get?
25
20
 
@@ -1,14 +1,30 @@
1
1
  require 'bcrypt'
2
2
  require 'fast_blank'
3
- require 'seraph/extensions/nil_class_blank'
4
3
 
5
4
  module Seraph
6
5
  class PasswordEncryptor
7
- using Extensions::NilClassBlank
6
+ private_class_method :new
8
7
 
9
8
  def self.call(password)
9
+ new(password).call
10
+ end
11
+
12
+ def call
10
13
  return false if String(password).blank?
11
- BCrypt::Password.create(password)
14
+ peppered_password = pepper.blank? ? password : "#{password}:#{pepper}"
15
+ BCrypt::Password.create(peppered_password)
16
+ end
17
+
18
+ def initialize(password)
19
+ @password = password
20
+ end
21
+
22
+ private
23
+
24
+ attr_reader :password
25
+
26
+ def pepper
27
+ String(Seraph.configuration.pepper)
12
28
  end
13
29
  end
14
30
  end
@@ -1,3 +1,3 @@
1
1
  module Seraph
2
- VERSION = '0.0.2'.freeze
2
+ VERSION = '0.0.3'.freeze
3
3
  end
data/seraph.gemspec CHANGED
@@ -37,6 +37,6 @@ Gem::Specification.new do |gem|
37
37
  gem.add_development_dependency 'rake', '~> 10.0'
38
38
  gem.add_development_dependency 'rspec', '~> 3.0'
39
39
  gem.add_development_dependency 'rubygems-tasks', '~> 0.2'
40
- gem.add_development_dependency 'fuubar'
41
- gem.add_development_dependency 'pry'
40
+ gem.add_development_dependency 'fuubar', '~> 2.0'
41
+ gem.add_development_dependency 'pry', '~> 0.10'
42
42
  end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+ require 'seraph/password_encryptor'
3
+
4
+ RSpec.describe Seraph::PasswordEncryptor do
5
+ describe '.call' do
6
+ let(:password) { 'foobar12' }
7
+ let(:encrypted) { described_class.call(password) }
8
+ let(:salt) { encrypted.salt }
9
+ subject(:encrypted_password) { encrypted.to_s }
10
+
11
+ it 'encrypts the password using BCrypt' do
12
+ expect(encrypted_password).to eq BCrypt::Engine.hash_secret(password, salt)
13
+ end
14
+
15
+ context 'when pepper is set' do
16
+ let(:pepper) { '9b8177d1d835fad6cc19b455d41ec64f6dcbe83a1af60eb598973f8fb6e29fb1' }
17
+ before do
18
+ Seraph.configure do |config|
19
+ config.pepper = pepper
20
+ end
21
+ end
22
+
23
+ it 'uses the pepper for encrypting the password' do
24
+ expect(encrypted_password).to eq BCrypt::Engine.hash_secret("#{password}:#{pepper}", salt)
25
+ end
26
+ end
27
+ end
28
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seraph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Szymon Szeliga
@@ -112,30 +112,30 @@ dependencies:
112
112
  name: fuubar
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '0'
117
+ version: '2.0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '0'
124
+ version: '2.0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: pry
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ">="
129
+ - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: '0'
131
+ version: '0.10'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ">="
136
+ - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '0'
138
+ version: '0.10'
139
139
  description: Looking for an authentication gem that doesn't make any assumptions about
140
140
  your setup? You've came to the right place.
141
141
  email: szeliga.szymon@gmail.com
@@ -160,7 +160,7 @@ files:
160
160
  - lib/seraph/password_encryptor.rb
161
161
  - lib/seraph/version.rb
162
162
  - seraph.gemspec
163
- - spec/password_encryptor_spec.rb
163
+ - spec/seraph/password_encryptor_spec.rb
164
164
  - spec/seraph_spec.rb
165
165
  - spec/spec_helper.rb
166
166
  homepage: https://rubygems.org/gems/seraph
@@ -188,6 +188,6 @@ signing_key:
188
188
  specification_version: 4
189
189
  summary: A simple framework-agnostic library for authentication
190
190
  test_files:
191
- - spec/password_encryptor_spec.rb
191
+ - spec/seraph/password_encryptor_spec.rb
192
192
  - spec/seraph_spec.rb
193
193
  - spec/spec_helper.rb
@@ -1,14 +0,0 @@
1
- require 'spec_helper'
2
- require 'seraph/password_encryptor'
3
-
4
- RSpec.describe Seraph::PasswordEncryptor do
5
- describe '.call' do
6
- let(:password) { 'foobar12' }
7
- subject { described_class.call(password) }
8
-
9
- it 'encrypts the password using BCrypt' do
10
- encrypted = subject
11
- expect(encrypted.to_s).to eq BCrypt::Engine.hash_secret(password, encrypted.salt)
12
- end
13
- end
14
- end