omniauth-goodgame 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/omniauth/goodgame/version.rb +1 -1
- data/lib/omniauth/strategies/goodgame.rb +27 -28
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '029c7684f5a75abc853c3b28bcfd78b70e52e66fd5d2ec5cd1c0265cb40acf73'
|
|
4
|
+
data.tar.gz: 00e53bdae1cd987413cb8390d01e187d372568e1fbd142cab65b2c2ffe245326
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8791c61174d8e8b99ce0051ff621a4fb1b9a7aeb92c0a2570cfd202bc245f1b05e25f6b4c3244fdd88dcbbe10055b9c255bd6bcb9f8b55799e72d0c55116dda7
|
|
7
|
+
data.tar.gz: 61bb7d5a5d95fdbfeef8bcde21811b910481b453e568d5399b86366ebb0127b474b3edc9f83bb40ad3055943006f2ae0ec050473df22e6d7becf5a8a48702bc5
|
|
@@ -1,60 +1,58 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'omniauth-oauth2'
|
|
2
2
|
|
|
3
3
|
module OmniAuth
|
|
4
4
|
module Strategies
|
|
5
5
|
class Goodgame < OmniAuth::Strategies::OAuth2
|
|
6
|
-
DEFAULT_SCOPE =
|
|
7
|
-
option :name, "goodgame"
|
|
6
|
+
DEFAULT_SCOPE = ''
|
|
8
7
|
|
|
8
|
+
option :name, 'goodgame'
|
|
9
|
+
option :authorize_options, %i[scope display]
|
|
9
10
|
option :client_options, {
|
|
10
|
-
site:
|
|
11
|
-
authorize_url:
|
|
12
|
-
token_url:
|
|
11
|
+
site: 'https://goodgame.ru',
|
|
12
|
+
authorize_url: '/oauth2/authorize',
|
|
13
|
+
token_url: '/oauth2/token',
|
|
13
14
|
auth_scheme: :request_body
|
|
14
15
|
}
|
|
15
|
-
|
|
16
16
|
option :access_token_options, {
|
|
17
|
-
header_format:
|
|
18
|
-
param_name:
|
|
17
|
+
header_format: 'Bearer %s',
|
|
18
|
+
param_name: 'access_token'
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
option :authorize_options, [:scope]
|
|
22
|
-
|
|
23
21
|
def request_phase
|
|
24
22
|
redirect client.auth_code
|
|
25
23
|
.authorize_url({ redirect_uri: callback_url }
|
|
26
|
-
.merge(authorize_params)).gsub(/%2[b,B]/,
|
|
24
|
+
.merge(authorize_params)).gsub(/%2[b,B]/, '+')
|
|
27
25
|
end
|
|
28
26
|
|
|
29
27
|
credentials do
|
|
30
|
-
hash = {
|
|
31
|
-
hash[
|
|
32
|
-
hash[
|
|
33
|
-
hash[
|
|
28
|
+
hash = { 'token' => access_token.token }
|
|
29
|
+
hash['refresh_token'] = access_token.refresh_token if access_token.refresh_token
|
|
30
|
+
hash['expires_at'] = access_token.expires_at if access_token.expires?
|
|
31
|
+
hash['expires'] = access_token.expires?
|
|
34
32
|
hash
|
|
35
33
|
end
|
|
36
34
|
|
|
37
|
-
uid { raw_info[
|
|
35
|
+
uid { raw_info['id'] }
|
|
38
36
|
|
|
39
37
|
info do
|
|
40
38
|
{
|
|
41
|
-
name: raw_info[
|
|
42
|
-
email: raw_info[
|
|
43
|
-
nickname: raw_info["username"],
|
|
44
|
-
description: raw_info["about"],
|
|
45
|
-
image: raw_info["avatar"],
|
|
46
|
-
urls: { Goodgame: raw_info["link"] }
|
|
39
|
+
name: raw_info['nickname'],
|
|
40
|
+
email: raw_info['email']
|
|
47
41
|
}
|
|
48
42
|
end
|
|
43
|
+
|
|
49
44
|
extra do
|
|
50
45
|
{
|
|
51
|
-
raw_info:
|
|
46
|
+
raw_info:
|
|
52
47
|
}
|
|
53
48
|
end
|
|
49
|
+
|
|
54
50
|
def raw_info
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
id = access_token.get("https://goodgame.ru/api/4/users/@me2?access_token=#{access_token.token}",
|
|
52
|
+
headers: { 'Accept' => 'application/json' }).parsed.fetch('id')
|
|
53
|
+
@raw_info =
|
|
54
|
+
access_token.get("https://goodgame.ru/api/4/users/#{id}?access_token=#{access_token.token}",
|
|
55
|
+
headers: { 'Accept' => 'application/json' }).parsed
|
|
58
56
|
end
|
|
59
57
|
|
|
60
58
|
def build_access_token
|
|
@@ -78,7 +76,7 @@ module OmniAuth
|
|
|
78
76
|
def authorize_params
|
|
79
77
|
super.tap do |params|
|
|
80
78
|
options[:authorize_options].each do |k|
|
|
81
|
-
params[k] = request.params[k.to_s] unless [nil,
|
|
79
|
+
params[k] = request.params[k.to_s] unless [nil, ''].include?(request.params[k.to_s])
|
|
82
80
|
end
|
|
83
81
|
params[:scope] = params[:scope] || DEFAULT_SCOPE
|
|
84
82
|
end
|
|
@@ -86,3 +84,4 @@ module OmniAuth
|
|
|
86
84
|
end
|
|
87
85
|
end
|
|
88
86
|
end
|
|
87
|
+
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: omniauth-goodgame
|
|
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
|
- Alex Seregin
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2023-09-
|
|
11
|
+
date: 2023-09-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: omniauth-oauth2
|