omniauth-fortnox-oauth2 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a4022f4d3f910ee1f59a350edebc056f1dd60b93c91895b93ce703757b163f57
4
- data.tar.gz: 186a3c2d187f38b97509e8b4594640104d8c70435b5e48aff812b433ae69b49f
3
+ metadata.gz: e867e1c0804b077222e57ec5d0bb96da3fcc642047b435949b65783dcec3e177
4
+ data.tar.gz: 465953deef868451d8670e3056d99a8ce38c8bb1ba5904dd2d5ec05cf3ab57ab
5
5
  SHA512:
6
- metadata.gz: 329f0f93ccb9daedc67ff40083b336dd3b9ca973256391805dec85693aee894b9c44338f52e98f4e5264a265597b8332939f9b135cea77630b592eb800bd9130
7
- data.tar.gz: 8e77814e839af30c89b41823255372ea40d0a5a97dc5bafca6b955b270d50dac5fed587f687458b4869424fa1946fb0846695628d35574e5ca30dd48619cf79b
6
+ metadata.gz: c38c7b304242bcf94d265e29a5c42e59e223ccaa790105eddc0b09b63190768fa61eb99a9798ea26d5e83180f91a1a1cc4c31b425f1191ed1923ee9bd59f6260
7
+ data.tar.gz: 43a72b8c8ce885db697f5a8bf0702a4549fe28b956f3f55e3bea76965168acbbfaf3ad53ec011235b5f347c097d9d73aa74233758eac5d1567234130d4bc85e3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- omniauth-fortnox-oauth2 (0.0.1)
4
+ omniauth-fortnox-oauth2 (0.0.3)
5
5
  omniauth-oauth2
6
6
 
7
7
  GEM
@@ -14,45 +14,29 @@ GEM
14
14
  crack (0.4.5)
15
15
  rexml
16
16
  diff-lcs (1.4.4)
17
- faraday (1.8.0)
18
- faraday-em_http (~> 1.0)
19
- faraday-em_synchrony (~> 1.0)
20
- faraday-excon (~> 1.1)
21
- faraday-httpclient (~> 1.0.1)
22
- faraday-net_http (~> 1.0)
23
- faraday-net_http_persistent (~> 1.1)
24
- faraday-patron (~> 1.0)
25
- faraday-rack (~> 1.0)
26
- multipart-post (>= 1.2, < 3)
17
+ faraday (2.7.2)
18
+ faraday-net_http (>= 2.0, < 3.1)
27
19
  ruby2_keywords (>= 0.0.4)
28
- faraday-em_http (1.0.0)
29
- faraday-em_synchrony (1.0.0)
30
- faraday-excon (1.1.0)
31
- faraday-httpclient (1.0.1)
32
- faraday-net_http (1.0.1)
33
- faraday-net_http_persistent (1.2.0)
34
- faraday-patron (1.0.0)
35
- faraday-rack (1.0.0)
20
+ faraday-net_http (3.0.2)
36
21
  hashdiff (1.0.1)
37
- hashie (4.1.0)
38
- jwt (2.2.3)
22
+ hashie (5.0.0)
23
+ jwt (2.6.0)
39
24
  method_source (1.0.0)
40
- multi_json (1.15.0)
41
25
  multi_xml (0.6.0)
42
- multipart-post (2.1.1)
43
- oauth2 (1.4.7)
44
- faraday (>= 0.8, < 2.0)
26
+ oauth2 (2.0.9)
27
+ faraday (>= 0.17.3, < 3.0)
45
28
  jwt (>= 1.0, < 3.0)
46
- multi_json (~> 1.3)
47
29
  multi_xml (~> 0.5)
48
- rack (>= 1.2, < 3)
49
- omniauth (2.0.4)
30
+ rack (>= 1.2, < 4)
31
+ snaky_hash (~> 2.0)
32
+ version_gem (~> 1.1)
33
+ omniauth (2.1.0)
50
34
  hashie (>= 3.4.6)
51
- rack (>= 1.6.2, < 3)
35
+ rack (>= 2.2.3)
52
36
  rack-protection
53
- omniauth-oauth2 (1.7.1)
54
- oauth2 (~> 1.4)
55
- omniauth (>= 1.9, < 3)
37
+ omniauth-oauth2 (1.8.0)
38
+ oauth2 (>= 1.4, < 3)
39
+ omniauth (~> 2.0)
56
40
  pry (0.13.1)
57
41
  coderay (~> 1.1)
58
42
  method_source (~> 1.0)
@@ -60,8 +44,8 @@ GEM
60
44
  byebug (~> 11.0)
61
45
  pry (~> 0.13.0)
62
46
  public_suffix (4.0.6)
63
- rack (2.2.3)
64
- rack-protection (2.1.0)
47
+ rack (3.0.3)
48
+ rack-protection (3.0.5)
65
49
  rack
66
50
  rake (13.0.6)
67
51
  rexml (3.2.5)
@@ -79,12 +63,17 @@ GEM
79
63
  rspec-support (~> 3.10.0)
80
64
  rspec-support (3.10.2)
81
65
  ruby2_keywords (0.0.5)
66
+ snaky_hash (2.0.1)
67
+ hashie
68
+ version_gem (~> 1.1, >= 1.1.1)
69
+ version_gem (1.1.1)
82
70
  webmock (3.14.0)
83
71
  addressable (>= 2.8.0)
84
72
  crack (>= 0.3.2)
85
73
  hashdiff (>= 0.4.0, < 2.0.0)
86
74
 
87
75
  PLATFORMS
76
+ arm64-darwin-21
88
77
  x86_64-darwin-19
89
78
 
90
79
  DEPENDENCIES
data/README.md CHANGED
@@ -46,6 +46,10 @@ Can also be set up with dynamic configuration:
46
46
  end)
47
47
  ```
48
48
 
49
+ Service account in Fortnox can be configured with the optional parameter `account_type`.
50
+ ```ruby
51
+ account_type: 'service'
52
+ ```
49
53
 
50
54
  You can now access the OmniAuth Fortnox OAuth2 URL: /auth/fortnox_oauth2
51
55
  Later a controller can be set up to handle the response after authentication, for example:
@@ -75,6 +79,17 @@ You can also configure the `client_options` by passing in any of the following s
75
79
 
76
80
  * `token_method`: Override the token_method used by the gem, default `:post`.
77
81
 
82
+ ## Note
83
+ Currently the only way to support multiple redirect uri's in Fortnox is to add them sperated using ` ` (space). This will work for the initial request to get the authorization code.
84
+ When trading the code for a token the `redirect_uri` will be matched using the string used in Fortnox developer portal. This is beeing changed but for now the workaround is to pass that string.
85
+ This can here be passed as an option `fortnox_redirect_uri`, it can contain one or multiple uri's.
86
+ This will need to exactly match the string in Fortnox.
87
+
88
+ For example:
89
+ ```ruby
90
+ env['omniauth.strategy'].options[:fortnox_redirect_uri] = 'https://test.test/callback https://second-test.test/callback'
91
+ ```
92
+
78
93
  ## Auth Hash
79
94
 
80
95
  Here's an example of an authentication hash available in the callback by accessing `request.env['omniauth.auth']`:
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Omniauth
4
4
  module FortnoxOAuth2
5
- VERSION = '0.0.1'
5
+ VERSION = '0.0.3'
6
6
  end
7
7
  end
@@ -18,8 +18,9 @@ module OmniAuth
18
18
  token_method: :post
19
19
  }
20
20
 
21
- option :authorize_options, %i[scope state]
21
+ option :authorize_options, %i[scope state account_type]
22
22
  option :provider_ignores_state, false
23
+ option :fortnox_redirect_uri, nil
23
24
 
24
25
  uid { raw_info['CompanyInformation']['OrganizationNumber'] }
25
26
 
@@ -57,7 +58,7 @@ module OmniAuth
57
58
  client_id: options['client_id'],
58
59
  response_type: 'code',
59
60
  scope: (options['scope'] || DEFAULT_SCOPE)
60
- }
61
+ }.merge( options['account_type'] ? { account_type: options['account_type'] } : {} )
61
62
 
62
63
  super
63
64
  end
@@ -66,11 +67,21 @@ module OmniAuth
66
67
  options[:callback_url] || (full_host + script_name + callback_path)
67
68
  end
68
69
 
70
+ # Currently the only way to support multiple redirect uri's in Fortnox
71
+ # is to add them sperated using ` ` (space). This will work for the
72
+ # initial request to get the authorization code.
73
+ # When trading the code for a token the `redirect_uri` will be matched
74
+ # using the string entered in Fortnox developer portal. This is beeing
75
+ # changed but for now the workaround is to pass that string.
76
+ # It can contain one or multiple uri's.
77
+ #
69
78
  def build_access_token
79
+ redirect_uri = options.fortnox_redirect_uri || callback_url
70
80
  verifier = request.params['code']
81
+
71
82
  client.auth_code.get_token(
72
83
  verifier,
73
- { redirect_uri: callback_url }.merge(token_params.to_hash(symbolize_keys: true)),
84
+ { redirect_uri: redirect_uri }.merge(token_params.to_hash(symbolize_keys: true)),
74
85
  deep_symbolize(options.auth_token_params)
75
86
  )
76
87
  end
@@ -116,6 +116,7 @@ describe OmniAuth::Strategies::FortnoxOauth2 do
116
116
  end
117
117
 
118
118
  before do
119
+ fortnox_oauth2.options.provider_ignores_state = true
119
120
  allow(fortnox_oauth2).to receive(:request) { error_request }
120
121
  end
121
122
 
@@ -288,5 +289,14 @@ describe OmniAuth::Strategies::FortnoxOauth2 do
288
289
  .to eq('companyinformation,invoice')
289
290
  end
290
291
  end
292
+
293
+ context 'when setting account_type in options' do
294
+ let(:options) { { 'account_type' => 'service' } }
295
+
296
+ it 'uses the new account_type' do
297
+ expect(fortnox_oauth2.authorize_params[:account_type])
298
+ .to eq('service')
299
+ end
300
+ end
291
301
  end
292
302
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-fortnox-oauth2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - svenne87
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-28 00:00:00.000000000 Z
11
+ date: 2023-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth-oauth2
@@ -129,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
129
  - !ruby/object:Gem::Version
130
130
  version: '0'
131
131
  requirements: []
132
- rubygems_version: 3.2.22
132
+ rubygems_version: 3.3.26
133
133
  signing_key:
134
134
  specification_version: 4
135
135
  summary: OmniAuth OAuth2 strategy for Fortnox