mojo_auth 0.1.0 → 0.1.1
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/CHANGELOG.md +4 -1
- data/README.md +10 -10
- data/lib/mojo_auth.rb +10 -10
- data/lib/mojo_auth/version.rb +1 -1
- data/mojo-auth.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2438e430058337110bce28f677f818deb79d1005
|
4
|
+
data.tar.gz: 68fca313b937214cb4c1db6976a47f3fef0ef959
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e22869bffbb1c25da7481b7628511b6f987817c743e9bd512bd67a94af74a7bcd81620fb40516acf2a717b633813c9c6ba13979125a6b51ba70c3d4a4a1decf
|
7
|
+
data.tar.gz: b5af5957bc87edec2279e2203e7a69ee04a044315424d0047afd8e0f0c8a9a8d1070616c9540ef68d09cfb86484f3b202d8f29d7cf87ff162c2183477849c6ee
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
# [develop](https://github.com/mojolingo/mojo-auth.rb)
|
2
2
|
|
3
|
-
# [v0.1.
|
3
|
+
# [v0.1.1](https://github.com/mojolingo/mojo-auth.rb/compare/v0.1.0...v0.1.1) - [2015-04-09](https://rubygems.org/gems/mojo_auth/versions/0.1.1)
|
4
|
+
* Bugfix: Remove newlines from passwords for compat with other libs
|
5
|
+
|
6
|
+
# [v0.1.0](https://github.com/mojolingo/mojo-auth.rb/compare/0e767e1c19b251a6dd3665e2f1f920fa237ac9cf...v0.1.0) - [2014-09-26](https://rubygems.org/gems/mojo_auth/versions/0.1.0)
|
4
7
|
* Initial release
|
data/README.md
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
[](http://badge.fury.io/rb/mojo_auth)
|
2
|
+
[](http://travis-ci.org/mojolingo/mojo-auth.rb)
|
3
3
|
[](https://gemnasium.com/mojolingo/mojo-auth.rb)
|
4
|
-
[](https://codeclimate.com/github/mojolingo/mojo-auth.rb)
|
5
|
+
[](https://coveralls.io/r/mojolingo/mojo-auth.rb?branch=develop)
|
6
|
+
[](http://inch-ci.org/github/mojolingo/mojo-auth.rb)
|
7
7
|
|
8
8
|
# mojo_auth
|
9
9
|
|
10
|
-
[MojoAuth](http://mojolingo.com
|
10
|
+
[MojoAuth](http://mojoauth.mojolingo.com) is a set of standard approaches to cross-app authentication based on [Hash-based Message Authentication Codes](http://en.wikipedia.org/wiki/Hash-based_message_authentication_code) (HMAC), inspired by ["A REST API For Access To TURN Services"](http://tools.ietf.org/html/draft-uberti-behave-turn-rest).
|
11
11
|
|
12
12
|
## Installation
|
13
13
|
|
@@ -32,20 +32,20 @@ require 'mojo_auth'
|
|
32
32
|
|
33
33
|
# Generate a shared secret
|
34
34
|
secret = MojoAuth.create_secret
|
35
|
-
# => "XyD+xeJHivzbOUe3vwdU6Z5vDe/vio34MxKX8HYViR0+p4t/NzaIpbK+9VwX\n5qHCj7m4f7UNRXgOJPXzn6MT0Q
|
35
|
+
# => "XyD+xeJHivzbOUe3vwdU6Z5vDe/vio34MxKX8HYViR0+p4t/NzaIpbK+9VwX\n5qHCj7m4f7UNRXgOJPXzn6MT0Q=="
|
36
36
|
|
37
37
|
# Create temporary credentials
|
38
38
|
credentials = MojoAuth.create_credentials(id: 'foobar', secret: secret)
|
39
|
-
# => {:username=>"1411837760:foobar", :password=>"wb6KxLj6NXcUaqNb1SlHH1V3QHw
|
39
|
+
# => {:username=>"1411837760:foobar", :password=>"wb6KxLj6NXcUaqNb1SlHH1V3QHw="}
|
40
40
|
|
41
41
|
# Test credentials
|
42
|
-
MojoAuth.test_credentials({username: "1411837760:foobar", password: "wb6KxLj6NXcUaqNb1SlHH1V3QHw
|
42
|
+
MojoAuth.test_credentials({username: "1411837760:foobar", password: "wb6KxLj6NXcUaqNb1SlHH1V3QHw="}, secret: secret)
|
43
43
|
# => "foobar"
|
44
44
|
MojoAuth.test_credentials({username: "1411837760:foobar", password: "wrongpassword"}, secret: secret)
|
45
45
|
# => false
|
46
46
|
|
47
47
|
# 1 day later
|
48
|
-
MojoAuth.test_credentials({username: "1411837760:foobar", password: "wb6KxLj6NXcUaqNb1SlHH1V3QHw
|
48
|
+
MojoAuth.test_credentials({username: "1411837760:foobar", password: "wb6KxLj6NXcUaqNb1SlHH1V3QHw="}, secret: secret)
|
49
49
|
# => false
|
50
50
|
```
|
51
51
|
|
data/lib/mojo_auth.rb
CHANGED
@@ -11,20 +11,20 @@ require 'mojo_auth/version'
|
|
11
11
|
#
|
12
12
|
# # Generate a shared secret
|
13
13
|
# secret = MojoAuth.create_secret
|
14
|
-
# # => "XyD+xeJHivzbOUe3vwdU6Z5vDe/vio34MxKX8HYViR0+p4t/NzaIpbK+9VwX\n5qHCj7m4f7UNRXgOJPXzn6MT0Q
|
14
|
+
# # => "XyD+xeJHivzbOUe3vwdU6Z5vDe/vio34MxKX8HYViR0+p4t/NzaIpbK+9VwX\n5qHCj7m4f7UNRXgOJPXzn6MT0Q=="
|
15
15
|
#
|
16
16
|
# # Create temporary credentials
|
17
17
|
# credentials = MojoAuth.create_credentials(id: 'foobar', secret: secret)
|
18
|
-
# # => {:username=>"1411837760:foobar", :password=>"wb6KxLj6NXcUaqNb1SlHH1V3QHw
|
18
|
+
# # => {:username=>"1411837760:foobar", :password=>"wb6KxLj6NXcUaqNb1SlHH1V3QHw="}
|
19
19
|
#
|
20
20
|
# # Test credentials
|
21
|
-
# MojoAuth.test_credentials({username: "1411837760:foobar", password: "wb6KxLj6NXcUaqNb1SlHH1V3QHw
|
21
|
+
# MojoAuth.test_credentials({username: "1411837760:foobar", password: "wb6KxLj6NXcUaqNb1SlHH1V3QHw="}, secret: secret)
|
22
22
|
# # => "foobar"
|
23
23
|
# MojoAuth.test_credentials({username: "1411837760:foobar", password: "wrongpassword"}, secret: secret)
|
24
24
|
# # => false
|
25
25
|
#
|
26
26
|
# # 1 day later
|
27
|
-
# MojoAuth.test_credentials({username: "1411837760:foobar", password: "wb6KxLj6NXcUaqNb1SlHH1V3QHw
|
27
|
+
# MojoAuth.test_credentials({username: "1411837760:foobar", password: "wb6KxLj6NXcUaqNb1SlHH1V3QHw="}, secret: secret)
|
28
28
|
# # => false
|
29
29
|
#
|
30
30
|
class MojoAuth
|
@@ -48,15 +48,15 @@ class MojoAuth
|
|
48
48
|
#
|
49
49
|
# @example Basic usage
|
50
50
|
# credentials = MojoAuth.create_credentials(secret: secret)
|
51
|
-
# # => {:username=>"1411837760", :password=>"wb6KxLj6NXcUaqNb1SlHH1V3QHw
|
51
|
+
# # => {:username=>"1411837760", :password=>"wb6KxLj6NXcUaqNb1SlHH1V3QHw="}
|
52
52
|
#
|
53
53
|
# @example Asserting an identity
|
54
54
|
# credentials = MojoAuth.create_credentials(id: 'foobar', secret: secret)
|
55
|
-
# # => {:username=>"1411837760:foobar", :password=>"wb6KxLj6NXcUaqNb1SlHH1V3QHw
|
55
|
+
# # => {:username=>"1411837760:foobar", :password=>"wb6KxLj6NXcUaqNb1SlHH1V3QHw="}
|
56
56
|
#
|
57
57
|
# @example Specifying an alternative TTL
|
58
58
|
# credentials = MojoAuth.create_credentials(ttl: 600, secret: secret)
|
59
|
-
# # => {:username=>"1411837760", :password=>"wb6KxLj6NXcUaqNb1SlHH1V3QHw
|
59
|
+
# # => {:username=>"1411837760", :password=>"wb6KxLj6NXcUaqNb1SlHH1V3QHw="}
|
60
60
|
#
|
61
61
|
def self.create_credentials(id: nil, secret: required, ttl: DAY_IN_SECONDS)
|
62
62
|
expiry_timestamp = (Time.now.utc + ttl).to_i
|
@@ -72,11 +72,11 @@ class MojoAuth
|
|
72
72
|
# @return [Boolean, String] whether or not the credentials are valid (were created using the specified secret) and current (have not yet expired). When the credentials assert an identity, that identity is returned.
|
73
73
|
#
|
74
74
|
# @example Testing correct credentials
|
75
|
-
# MojoAuth.test_credentials({username: "1411837760", password: "wb6KxLj6NXcUaqNb1SlHH1V3QHw
|
75
|
+
# MojoAuth.test_credentials({username: "1411837760", password: "wb6KxLj6NXcUaqNb1SlHH1V3QHw="}, secret: secret)
|
76
76
|
# # => true
|
77
77
|
#
|
78
78
|
# @example Testing correct ID-asserting credentials
|
79
|
-
# MojoAuth.test_credentials({username: "1411837760:foobar", password: "wb6KxLj6NXcUaqNb1SlHH1V3QHw
|
79
|
+
# MojoAuth.test_credentials({username: "1411837760:foobar", password: "wb6KxLj6NXcUaqNb1SlHH1V3QHw="}, secret: secret)
|
80
80
|
# # => "foobar"
|
81
81
|
#
|
82
82
|
# @example Testing incorrect credentials
|
@@ -107,7 +107,7 @@ class MojoAuth
|
|
107
107
|
#
|
108
108
|
# @return [String] the message signed with the shared secret
|
109
109
|
def sign(message)
|
110
|
-
Base64.encode64(OpenSSL::HMAC.digest('sha1', @secret, message))
|
110
|
+
Base64.encode64(OpenSSL::HMAC.digest('sha1', @secret, message)).chomp
|
111
111
|
end
|
112
112
|
|
113
113
|
# Assert a set of credentials
|
data/lib/mojo_auth/version.rb
CHANGED
data/mojo-auth.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ['ben@langfeld.me']
|
11
11
|
spec.summary = 'Implementation of MojoAuth in Ruby'
|
12
12
|
spec.description = 'MojoAuth is a set of standard approaches to cross-app authentication based on HMAC.'
|
13
|
-
spec.homepage = 'https://github.com/mojolingo/
|
13
|
+
spec.homepage = 'https://github.com/mojolingo/mojo-auth.rb'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mojo_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Langfeld
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -186,7 +186,7 @@ files:
|
|
186
186
|
- mojo-auth.gemspec
|
187
187
|
- spec/mojo_auth_spec.rb
|
188
188
|
- spec/spec_helper.rb
|
189
|
-
homepage: https://github.com/mojolingo/
|
189
|
+
homepage: https://github.com/mojolingo/mojo-auth.rb
|
190
190
|
licenses:
|
191
191
|
- MIT
|
192
192
|
metadata: {}
|
@@ -206,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
206
206
|
version: '0'
|
207
207
|
requirements: []
|
208
208
|
rubyforge_project:
|
209
|
-
rubygems_version: 2.
|
209
|
+
rubygems_version: 2.4.5
|
210
210
|
signing_key:
|
211
211
|
specification_version: 4
|
212
212
|
summary: Implementation of MojoAuth in Ruby
|