omniauth-sberbusiness 1.0.3 → 1.0.4
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/.gitignore +1 -0
- data/lib/omniauth/sberbusiness/version.rb +1 -1
- data/lib/omniauth/strategies/sberbusiness.rb +23 -20
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc6a24d6b570f4a4ee525fca24fb894a5a3bd732be93b89b15d21c01c8442e3c
|
4
|
+
data.tar.gz: 3557c296ec5f0b6b7fb08866f84565e5664bac34244bc77306f32fa41c71292a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b720db90f54c0ef88124077f3681a0de7430ebe591a9429fb3bbf930ad2410014069d0968dd908885b8313cdbf456775425468ca08f9c20dc67403e20493a882
|
7
|
+
data.tar.gz: e9baea1e868b23932099630ae310af10ed9b197498b77aab832941974715e50a3135d717212576b70f3336c5b519d2af5f95a996435e5421900e93eb5dbe24a3
|
data/.gitignore
CHANGED
@@ -6,6 +6,7 @@ require 'base64'
|
|
6
6
|
|
7
7
|
module OmniAuth
|
8
8
|
module Strategies
|
9
|
+
# https://developer.sberbank.ru/doc/v3/sbbol
|
9
10
|
class Sberbusiness < OmniAuth::Strategies::OAuth2
|
10
11
|
class NoRawData < StandardError; end
|
11
12
|
|
@@ -15,11 +16,14 @@ module OmniAuth
|
|
15
16
|
|
16
17
|
option :name, 'sberbusiness'
|
17
18
|
|
19
|
+
option :test, false
|
20
|
+
|
18
21
|
option :client_options,
|
19
|
-
site: 'https://fintech.sberbank.ru:9443',
|
20
|
-
token_url: 'https://fintech.sberbank.ru:9443/ic/sso/api/v2/oauth/token',
|
21
|
-
authorize_url: 'https://sbi.sberbank.ru:9443/ic/sso/api/v2/oauth/authorize'
|
22
|
-
|
22
|
+
site: 'https://fintech.sberbank.ru:9443',
|
23
|
+
token_url: 'https://fintech.sberbank.ru:9443/ic/sso/api/v2/oauth/token',
|
24
|
+
authorize_url: 'https://sbi.sberbank.ru:9443/ic/sso/api/v2/oauth/authorize',
|
25
|
+
user_info_path: '/ic/sso/api/v2/oauth/user-info',
|
26
|
+
client_info_path: '/api/v1/client-info'
|
23
27
|
|
24
28
|
option :authorize_options, %i[scope response_type client_type client_id state nonce]
|
25
29
|
|
@@ -42,28 +46,33 @@ module OmniAuth
|
|
42
46
|
accounts: raw_info['accounts'],
|
43
47
|
id: raw_info['sub'],
|
44
48
|
inn: raw_info['inn'],
|
45
|
-
|
46
|
-
provider: 'sberbusiness'
|
49
|
+
provider: options.name
|
47
50
|
}
|
48
51
|
end
|
49
52
|
|
50
53
|
extra do
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
+
if options.test
|
55
|
+
{
|
56
|
+
'raw_info' => raw_info,
|
57
|
+
'credentials' => credentials
|
58
|
+
}
|
59
|
+
else
|
60
|
+
{ 'raw_info' => raw_info }
|
61
|
+
end
|
54
62
|
end
|
55
63
|
|
56
|
-
# https://developer.sberbank.ru/doc/v1/sberbank-id/datareq
|
57
64
|
def raw_info
|
58
65
|
access_token.options[:mode] = :header
|
59
66
|
@raw_info ||= begin
|
60
|
-
|
61
|
-
result = access_token.get('/ic/sso/api/v2/oauth/user-info', headers: info_headers).body
|
67
|
+
result = access_token.get(options.client_options['user_info_path'], headers: info_headers).body
|
62
68
|
# декодируем ответ:
|
63
69
|
decoded_data = result.split('.').map { |code| decrypt(code) rescue {}}
|
64
70
|
result = decoded_data.reduce(:merge)
|
65
|
-
|
66
|
-
result
|
71
|
+
# здесь нужен скоп специальный, а на тесте мы его задать не можем
|
72
|
+
return result unless options.test
|
73
|
+
|
74
|
+
org_info = access_token.get(options.client_options['client_info_path'], headers: info_headers).body
|
75
|
+
result.merge({ client_info: org_info.force_encoding('UTF-8') })
|
67
76
|
end
|
68
77
|
end
|
69
78
|
|
@@ -71,7 +80,6 @@ module OmniAuth
|
|
71
80
|
JSON.parse(Base64.urlsafe_decode64(msg).force_encoding(Encoding::UTF_8))
|
72
81
|
end
|
73
82
|
|
74
|
-
# https://developer.sberbank.ru/doc/v1/sberbank-id/authcodereq
|
75
83
|
def authorize_params
|
76
84
|
super.tap do |params|
|
77
85
|
%w[state scope response_type client_type client_id nonce].each do |v|
|
@@ -80,10 +88,6 @@ module OmniAuth
|
|
80
88
|
params[v.to_sym] = request.params[v]
|
81
89
|
end
|
82
90
|
params[:scope] ||= DEFAULT_SCOPE
|
83
|
-
# if you want redirect to other host and save old host
|
84
|
-
state = session['omniauth.origin'] || env['HTTP_REFERER']
|
85
|
-
params[:state] = state
|
86
|
-
session['omniauth.state'] = state
|
87
91
|
params[:nonce] = SecureRandom.hex(16)
|
88
92
|
end
|
89
93
|
end
|
@@ -104,7 +108,6 @@ module OmniAuth
|
|
104
108
|
end
|
105
109
|
|
106
110
|
def info_options
|
107
|
-
# https://developer.sberbank.ru/doc/v1/sberbank-id/dataanswerparametrs
|
108
111
|
fields = %w[
|
109
112
|
sub family_name given_name middle_name birthdate email phone_number
|
110
113
|
address_reg identification inn snils gender
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-sberbusiness
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergei Baksheev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-07-
|
11
|
+
date: 2021-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: omniauth-oauth2
|
@@ -67,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
requirements: []
|
70
|
-
rubygems_version: 3.2
|
70
|
+
rubygems_version: 3.1.2
|
71
71
|
signing_key:
|
72
72
|
specification_version: 4
|
73
73
|
summary: Sberbusiness OAuth2 Strategy for OmniAuth
|