yt-auth 0.2.0 → 0.2.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 -0
- data/README.md +7 -4
- data/lib/yt/auth/version.rb +1 -1
- data/lib/yt/auth.rb +8 -9
- data/yt-auth.gemspec +1 -0
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97e3f1d9311c6bdf1ff0159c3758c8632fc7ba11
|
4
|
+
data.tar.gz: bd734cf1115761ec0f5ae1ecda390786e2788fa8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74b7103a71bf2daa3684599321caa24ddda7537d6c20b3fca014f057854c9f067690f8d16ba13cf7f4ee9404a5a90cef2e1625efd6e544d58deb7b35a40b89fc
|
7
|
+
data.tar.gz: 501af972f4f38fe87af8f6e3660aed39418a17a77c882eac54e9d00510f35881cbbb90f561dc50ba98d99c7a82c259ba5ed153ef6c49011eaabd6c75da412a0c
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,10 @@ For more information about changelogs, check
|
|
6
6
|
[Keep a Changelog](http://keepachangelog.com) and
|
7
7
|
[Vandamme](http://tech-angels.github.io/vandamme).
|
8
8
|
|
9
|
+
## 0.2.1 - 2017-03-29
|
10
|
+
|
11
|
+
* [ENHANCEMENT] Speed up process by fetching email with 1 HTTP request (not 2).
|
12
|
+
|
9
13
|
## 0.2.0 - 2017-03-29
|
10
14
|
|
11
15
|
**How to upgrade**
|
data/README.md
CHANGED
@@ -1,7 +1,11 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
Authenticate users with their Google account
|
2
|
+
============================================
|
3
3
|
|
4
|
-
Yt::Auth
|
4
|
+
Yt::Auth lets you easily authenticate users of your website by means of
|
5
|
+
their Google-based email address.
|
6
|
+
|
7
|
+
With Yt::Auth, it is easy to limit access to your app to a few users without
|
8
|
+
the need for them to create a username and password.
|
5
9
|
|
6
10
|
The **source code** is available on [GitHub](https://github.com/fullscreen/yt-auth) and the **documentation** on [RubyDoc](http://www.rubydoc.info/gems/yt-auth/frames).
|
7
11
|
|
@@ -55,7 +59,6 @@ Yt::Auth.new(redirect_uri: redirect_uri, code: code).email
|
|
55
59
|
# => Yt::HTTPError: Invalid authorization code.
|
56
60
|
```
|
57
61
|
|
58
|
-
|
59
62
|
How to contribute
|
60
63
|
=================
|
61
64
|
|
data/lib/yt/auth/version.rb
CHANGED
data/lib/yt/auth.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'jwt'
|
1
2
|
require 'yt/config'
|
2
3
|
require 'yt/http_request'
|
3
4
|
|
@@ -27,8 +28,7 @@ module Yt
|
|
27
28
|
|
28
29
|
# @return [String] the email of an authenticated Google account.
|
29
30
|
def email
|
30
|
-
|
31
|
-
response.body['email']
|
31
|
+
profile['email']
|
32
32
|
end
|
33
33
|
|
34
34
|
private
|
@@ -42,18 +42,17 @@ module Yt
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
def email_params
|
46
|
-
{}.tap do |params|
|
47
|
-
params[:path] = '/oauth2/v2/userinfo'
|
48
|
-
params[:headers] = {Authorization: "Bearer #{tokens['access_token']}"}
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
45
|
# @return [Hash] the tokens of an authenticated Google account.
|
53
46
|
def tokens
|
54
47
|
HTTPRequest.new(tokens_params).run.body
|
55
48
|
end
|
56
49
|
|
50
|
+
# @return [Hash] the profile of an authenticated Google account.
|
51
|
+
def profile
|
52
|
+
decoded_tokens = JWT.decode tokens['id_token'], nil, false
|
53
|
+
decoded_tokens[0]
|
54
|
+
end
|
55
|
+
|
57
56
|
def tokens_params
|
58
57
|
{}.tap do |params|
|
59
58
|
params[:host] = 'accounts.google.com'
|
data/yt-auth.gemspec
CHANGED
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.require_paths = ['lib']
|
24
24
|
|
25
25
|
spec.add_dependency 'yt-support', '>= 0.1.1'
|
26
|
+
spec.add_dependency 'jwt', '>= 1.5.6'
|
26
27
|
|
27
28
|
spec.add_development_dependency 'bundler', '~> 1.14'
|
28
29
|
spec.add_development_dependency 'rspec', '~> 3.5'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yt-auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Claudio Baccigalupo
|
@@ -25,6 +25,20 @@ dependencies:
|
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: 0.1.1
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: jwt
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 1.5.6
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 1.5.6
|
28
42
|
- !ruby/object:Gem::Dependency
|
29
43
|
name: bundler
|
30
44
|
requirement: !ruby/object:Gem::Requirement
|