simple_google_auth 0.0.4 → 0.0.5
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/lib/simple_google_auth.rb +7 -2
- data/lib/simple_google_auth/receiver.rb +7 -7
- data/lib/simple_google_auth/version.rb +1 -1
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17bdbddcd052da79050cd43d146b6ba3070a808d
|
4
|
+
data.tar.gz: 565fffa60eaef47bb69710a1830ee4315e73bf59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a83902d120549033da2bd08cd155e4f419dd9e512ef9a3a9240a654c3238119b36d9818feacdcdc8fcdd85ed8d2cb22a08e5df4a2fa0d7102c493e2360c85730
|
7
|
+
data.tar.gz: 08e7e440d0c2c27142c7229e1cc88d9a26df65d4ce3ff7d45f3e2195e495a4cef5136c81b08d42cd2acf4517b8cda8b02d73e749c3f04dbf30ff8a3606ae7b23
|
data/lib/simple_google_auth.rb
CHANGED
@@ -14,7 +14,12 @@ module SimpleGoogleAuth
|
|
14
14
|
:state_session_key_name,
|
15
15
|
:data_session_key_name,
|
16
16
|
:request_parameters
|
17
|
-
)
|
17
|
+
) do
|
18
|
+
def get_or_call(attribute)
|
19
|
+
value = send(attribute)
|
20
|
+
value.respond_to?(:call) ? value.call : value
|
21
|
+
end
|
22
|
+
end
|
18
23
|
|
19
24
|
mattr_accessor :config
|
20
25
|
self.config = Config.new
|
@@ -26,7 +31,7 @@ module SimpleGoogleAuth
|
|
26
31
|
def self.uri(state)
|
27
32
|
query = config.request_parameters.merge(
|
28
33
|
response_type: "code",
|
29
|
-
client_id: config.client_id,
|
34
|
+
client_id: config.get_or_call(:client_id),
|
30
35
|
redirect_uri: config.redirect_uri,
|
31
36
|
state: state
|
32
37
|
)
|
@@ -8,11 +8,11 @@ module SimpleGoogleAuth
|
|
8
8
|
|
9
9
|
ensure_params_are_correct(request, config)
|
10
10
|
auth_data = obtain_authentication_data(request.params["code"], config)
|
11
|
-
id_data = decode_id_data(auth_data)
|
11
|
+
id_data = decode_id_data(auth_data.delete("id_token"))
|
12
12
|
|
13
13
|
raise Error, "Authentication failed" unless config.authenticate.call(id_data)
|
14
14
|
|
15
|
-
request.session[config.data_session_key_name] = id_data
|
15
|
+
request.session[config.data_session_key_name] = id_data.merge(auth_data)
|
16
16
|
|
17
17
|
path = request.session[config.state_session_key_name][32..-1]
|
18
18
|
path = "/" if path.blank?
|
@@ -54,8 +54,8 @@ module SimpleGoogleAuth
|
|
54
54
|
request = Net::HTTP::Post.new(uri.request_uri)
|
55
55
|
request.set_form_data(
|
56
56
|
code: code,
|
57
|
-
client_id: config.client_id,
|
58
|
-
client_secret: config.client_secret,
|
57
|
+
client_id: config.get_or_call(:client_id),
|
58
|
+
client_secret: config.get_or_call(:client_secret),
|
59
59
|
redirect_uri: config.redirect_uri,
|
60
60
|
grant_type: "authorization_code"
|
61
61
|
)
|
@@ -66,10 +66,10 @@ module SimpleGoogleAuth
|
|
66
66
|
JSON.parse(response.body)
|
67
67
|
end
|
68
68
|
|
69
|
-
def decode_id_data(
|
70
|
-
id_data_64 =
|
69
|
+
def decode_id_data(id_data)
|
70
|
+
id_data_64 = id_data.split(".")[1]
|
71
71
|
id_data_64 << "=" until id_data_64.length % 4 == 0
|
72
|
-
|
72
|
+
JSON.parse(Base64.decode64(id_data_64))
|
73
73
|
end
|
74
74
|
end
|
75
75
|
end
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_google_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roger Nesbitt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 3.2.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.2.0
|
27
27
|
description: An extremely easy way to protect your site by requiring Google logins
|
@@ -32,15 +32,15 @@ executables: []
|
|
32
32
|
extensions: []
|
33
33
|
extra_rdoc_files: []
|
34
34
|
files:
|
35
|
-
- MIT-LICENSE
|
36
|
-
- README.md
|
37
|
-
- Rakefile
|
38
35
|
- config/routes.rb
|
39
|
-
- lib/simple_google_auth.rb
|
40
36
|
- lib/simple_google_auth/controller.rb
|
41
37
|
- lib/simple_google_auth/engine.rb
|
42
38
|
- lib/simple_google_auth/receiver.rb
|
43
39
|
- lib/simple_google_auth/version.rb
|
40
|
+
- lib/simple_google_auth.rb
|
41
|
+
- MIT-LICENSE
|
42
|
+
- Rakefile
|
43
|
+
- README.md
|
44
44
|
homepage: https://github.com/mogest/simple_google_auth
|
45
45
|
licenses:
|
46
46
|
- MIT
|
@@ -51,17 +51,17 @@ require_paths:
|
|
51
51
|
- lib
|
52
52
|
required_ruby_version: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
|
-
- -
|
54
|
+
- - '>='
|
55
55
|
- !ruby/object:Gem::Version
|
56
56
|
version: '0'
|
57
57
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
requirements: []
|
63
63
|
rubyforge_project:
|
64
|
-
rubygems_version: 2.
|
64
|
+
rubygems_version: 2.0.14
|
65
65
|
signing_key:
|
66
66
|
specification_version: 4
|
67
67
|
summary: Super simple Google authentication for your Rails site
|