seraph 0.0.2 → 0.0.3
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 +4 -4
- data/README.md +5 -10
- data/lib/seraph/password_encryptor.rb +19 -3
- data/lib/seraph/version.rb +1 -1
- data/seraph.gemspec +2 -2
- data/spec/seraph/password_encryptor_spec.rb +28 -0
- metadata +11 -11
- data/spec/password_encryptor_spec.rb +0 -14
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c38bec486a10c2137abb51d2960a95863594eb71
|
|
4
|
+
data.tar.gz: ea8f366ee742c81b9bf61f0b90a2da7e0b60389a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1e5d554f25769f57f42cc5d9e916ae00cb2f85cc15b229884f25e3a57d41f7c9c485efdb24682c8671ff78abb14b20367f8bdac9686ca1adc6a5db34d90fa709
|
|
7
|
+
data.tar.gz: 82c075c768a468fe62b7714e13ec9ca5714884aee418b064fb8676a4f766eec5e0df5fd018a5946ea108c67e6d90862aa701800d5d2786b465a2a2e57f1e01c3
|
data/README.md
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
# seraph
|
|
2
|
-
[](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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
data/lib/seraph/version.rb
CHANGED
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.
|
|
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
|