omniauth-gov 0.1.4 → 0.1.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: af4525bfa961b172289a862e7dee70a2eeb78f5ef93e0d8dbd9dcf007b3c79cc
4
- data.tar.gz: b1d70bc16edeb44c561539f73005472271a1f571f671b65e6eaec0a600d64c1e
3
+ metadata.gz: 7e8838d0aa21b42f3fd34e55119cd4e09b0b0a06f8f270b763eb89c02dcbc965
4
+ data.tar.gz: feefa806757d036278f21b0631f43c49212ee2faa286297686ee04ab3155c308
5
5
  SHA512:
6
- metadata.gz: e6215025868df7e05e8e1efd8b58f6476319d670f96bd6c4f797becf21bc69916b13cd18a0ecc657d29e7395898a66a4b8cef7d755994c879c1b0b0c2faab1c4
7
- data.tar.gz: 3e1d460cfb370a8bee1d083226ea4e86fa8943d24188cae71b23bf0d9e262653103b7e6feabffb4f15787e85c3b50f8639347928b4a1b2b239c0c1a33fad4b30
6
+ metadata.gz: 287b802208398e3bfbc99d560fb2402878a1029035d053ef0dd0dc75f1ed5c48c09f9ed12dabe8a2f25c89258d840e59dc15d88d6a2f22c58ffbaad0280cb009
7
+ data.tar.gz: fe04c521d519f874bc91596dba667bfbd7dc12de4eab13a104067dfc24073767a6d1523e9785fab53e45e1354e3b94ee28e5e579e42c581cf84512d3920952dc
data/README.md CHANGED
@@ -10,7 +10,7 @@ Estratégia omniauth para integração do Login Único do governo brasileiro ao
10
10
  gem 'omniauth', '1.9.1'
11
11
  gem "omniauth-rails_csrf_protection", '0.1.2'
12
12
  gem 'omniauth-oauth2'
13
- gem 'omniauth-gov', '~> 0.1.3'
13
+ gem 'omniauth-gov', '~> 0.1.5'
14
14
  ```
15
15
 
16
16
  ## Configuração devise
@@ -24,8 +24,7 @@ Em `config/initializers/devise.rb.rb`
24
24
  ENV['client_id'],
25
25
  ENV['client_secret'],
26
26
  scope: 'openid+email+profile+govbr_confiabilidades+',
27
- callback_path: '/callback-da-aplicacao',
28
- app_url: "https://endereco-do-app.gov.br"
27
+ callback_path: '/callback-da-aplicacao'
29
28
 
30
29
  config.omniauth_path_prefix = '/prefixo-devise/prefixo-omniauth'
31
30
  end
@@ -127,4 +126,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
127
126
 
128
127
  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
129
128
 
130
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
129
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -3,11 +3,6 @@ require 'omniauth-oauth2'
3
3
  module Omniauth
4
4
  module Strategies
5
5
  class Gov < OmniAuth::Strategies::OAuth2
6
- option :client_options, {
7
- site: 'https://sso.acesso.gov.br',
8
- authorize_url: 'https://sso.acesso.gov.br/authorize',
9
- token_url: 'https://sso.acesso.gov.br/token'
10
- }
11
6
  option :pkce, true
12
7
 
13
8
  credentials do
@@ -40,7 +35,16 @@ module Omniauth
40
35
  'raw_info': raw_info
41
36
  }
42
37
  end
38
+
39
+ def client
40
+ options.client_options.merge!({connection_opts: {request: {params_encoder: GovBr::ParamsEncoder}}})
41
+ ::OAuth2::Client.new(options.client_id, options.client_secret, deep_symbolize(options.client_options))
42
+ end
43
43
 
44
+ def request_phase
45
+ redirect client.auth_code.authorize_url({:redirect_uri => callback_url}.merge(authorize_params))
46
+ end
47
+
44
48
  def raw_info
45
49
  @raw_info ||= JWT.decode(credentials["id_token"], nil, false)[0]
46
50
  end
@@ -52,11 +56,6 @@ module Omniauth
52
56
  end
53
57
  end
54
58
 
55
- def client
56
- options.client_options.merge!({connection_opts: {request: {params_encoder: GovBr::ParamsEncoder}}})
57
- ::OAuth2::Client.new(options.client_id, options.client_secret, deep_symbolize(options.client_options))
58
- end
59
-
60
59
  def authorize_params # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
61
60
  options.authorize_params[:state] = SecureRandom.hex(24)
62
61
  options.authorize_params[:client_id] = options[:client_id]
@@ -75,7 +74,7 @@ module Omniauth
75
74
 
76
75
  def build_access_token
77
76
  verifier = request.params["code"]
78
- redirect_uri = "#{options.app_url}/#{options.callback_path}".gsub!(%r{/+}, '/')
77
+ redirect_uri = "#{OmniAuth.config.full_host}/#{options.callback_path}".gsub!(%r{/+}, '/')
79
78
 
80
79
  atoken = client.auth_code.get_token(
81
80
  verifier,
@@ -87,4 +86,7 @@ module Omniauth
87
86
  end
88
87
  end
89
88
 
89
+ end
90
+ end
91
+
90
92
  OmniAuth.config.add_camelization 'gov', 'Gov'
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module Gov
3
- VERSION = "0.1.4"
3
+ VERSION = "0.1.6"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-gov
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Ricardo
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-07-29 00:00:00.000000000 Z
12
+ date: 2024-08-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: omniauth