omniauth-sberbusiness 1.0.0 → 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 +28 -21
- data/omniauth-sberbusiness-1.0.0.gem +0 -0
- data/omniauth-sberbusiness-1.0.2.gem +0 -0
- metadata +5 -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://
|
20
|
-
token_url: 'https://
|
21
|
-
authorize_url: 'https://
|
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,32 +46,40 @@ 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
|
-
decoded_data = result.split('.').map { |code|
|
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
|
|
70
|
-
|
79
|
+
def decrypt(msg)
|
80
|
+
JSON.parse(Base64.urlsafe_decode64(msg).force_encoding(Encoding::UTF_8))
|
81
|
+
end
|
82
|
+
|
71
83
|
def authorize_params
|
72
84
|
super.tap do |params|
|
73
85
|
%w[state scope response_type client_type client_id nonce].each do |v|
|
@@ -76,10 +88,6 @@ module OmniAuth
|
|
76
88
|
params[v.to_sym] = request.params[v]
|
77
89
|
end
|
78
90
|
params[:scope] ||= DEFAULT_SCOPE
|
79
|
-
# if you want redirect to other host and save old host
|
80
|
-
state = session['omniauth.origin'] || env['HTTP_REFERER']
|
81
|
-
params[:state] = state
|
82
|
-
session['omniauth.state'] = state
|
83
91
|
params[:nonce] = SecureRandom.hex(16)
|
84
92
|
end
|
85
93
|
end
|
@@ -100,7 +108,6 @@ module OmniAuth
|
|
100
108
|
end
|
101
109
|
|
102
110
|
def info_options
|
103
|
-
# https://developer.sberbank.ru/doc/v1/sberbank-id/dataanswerparametrs
|
104
111
|
fields = %w[
|
105
112
|
sub family_name given_name middle_name birthdate email phone_number
|
106
113
|
address_reg identification inn snils gender
|
Binary file
|
Binary file
|
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
|
@@ -45,6 +45,8 @@ files:
|
|
45
45
|
- lib/omniauth-sberbusiness.rb
|
46
46
|
- lib/omniauth/sberbusiness/version.rb
|
47
47
|
- lib/omniauth/strategies/sberbusiness.rb
|
48
|
+
- omniauth-sberbusiness-1.0.0.gem
|
49
|
+
- omniauth-sberbusiness-1.0.2.gem
|
48
50
|
- omniauth-sberbusiness.gemspec
|
49
51
|
homepage: https://github.com/insales/omniauth-sberbusiness
|
50
52
|
licenses:
|
@@ -65,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
67
|
- !ruby/object:Gem::Version
|
66
68
|
version: '0'
|
67
69
|
requirements: []
|
68
|
-
rubygems_version: 3.2
|
70
|
+
rubygems_version: 3.1.2
|
69
71
|
signing_key:
|
70
72
|
specification_version: 4
|
71
73
|
summary: Sberbusiness OAuth2 Strategy for OmniAuth
|