omniauth-gov 0.1.5 → 0.1.7

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: 9a78473bf035ebd11bccaff000615db2459c9b117a43f206be6c3222ffc5f768
4
- data.tar.gz: 280a14547cb019b1adae1dc052992d3fc6db111826449a54fcd34daf6b56ad48
3
+ metadata.gz: c6840a35099a1ca67e4d477aa22b010b3bfe6b3a774634002a4ecb21967e3f3c
4
+ data.tar.gz: 9769699d8ee31a1359fe1435bbdf2c6b39bc013ab28dac419d7f8716693bacc7
5
5
  SHA512:
6
- metadata.gz: 4920fcdd29bb499c30c921f982be4517268c72d70287a66e8c4ac3a6c0080fc61c2d3865bd3ef5bc029355095cf6b59bdfb7442d3c6410c74358cb24c6b6f815
7
- data.tar.gz: 5fd852141ac9740ca2bed96c707f1f98cc287f8ea652cea10a8be1f811071a49705a2460f5766ad20836321b9389b987e6a19ef4d0fa575c123d1440ab53308a
6
+ metadata.gz: b0856e71109b9cd2345d77e74e11e743ab9d8ce4c67aa5ef6762bfb75b24b5be88963a7b2645d2684ed3ecef62afede57eacb4eafedd4b56b07181f7e66710ac
7
+ data.tar.gz: 4848581c3d8029cba39e26cc803c42799664197daad6d0cae93c1480dc01fa62d0817501da16386ece9f858903b2ed93b6142667a3966bb49859be50c5ca4f56
data/README.md CHANGED
@@ -24,7 +24,12 @@ 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'
27
+ callback_path: '/callback-da-aplicacao',
28
+ client_options: {
29
+ site: 'https://sso.acesso.gov.br', # Ambiente de produção.
30
+ authorize_url: 'https://sso.acesso.gov.br/authorize', # Ambiente de produção.
31
+ token_url: 'https://sso.acesso.gov.br/token' # Ambiente de produção.
32
+ }
28
33
 
29
34
  config.omniauth_path_prefix = '/prefixo-devise/prefixo-omniauth'
30
35
  end
@@ -34,7 +39,7 @@ Em `config/initializers/devise.rb.rb`
34
39
  Em `config/initializer/omniauth.rb`
35
40
 
36
41
  ```ruby
37
- OmniAuth.config.full_host = "<host-da-aplicacao-com-protocolo>"
42
+ OmniAuth.config.full_host = "https://endereco-do-app.gov.br"
38
43
  OmniAuth.config.logger = Rails.logger
39
44
  ```
40
45
 
@@ -121,6 +126,16 @@ devise :database_authenticatable,
121
126
 
122
127
  ```
123
128
 
129
+ ## View
130
+ Em `sessions/new.html.erb`
131
+ ```ruby
132
+ <%= button_to omniauth_authorize_path(resource_name, :gov), class: 'gov-br-btn sign-in br-button middle sign-in w-100 is-primary mt-3 mb-3', data: { turbo: false } do %>
133
+ <i class="icon fa fa-user fa-lg" style="color: rgb(255, 255, 255);"></i>&nbsp;
134
+ <span style="font-weight: normal;">Entrar com</span>&nbsp;
135
+ <span style="font-size: 20px; font-weight: bold;"> gov.br</span>
136
+ <% end %>
137
+ ```
138
+
124
139
  ## Licença
125
140
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
126
141
 
@@ -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]
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module Gov
3
- VERSION = "0.1.5"
3
+ VERSION = "0.1.7"
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.5
4
+ version: 0.1.7
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-30 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
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
149
  - !ruby/object:Gem::Version
150
150
  version: '0'
151
151
  requirements: []
152
- rubygems_version: 3.4.19
152
+ rubygems_version: 3.2.3
153
153
  signing_key:
154
154
  specification_version: 4
155
155
  summary: Official OmniAuth strategy for GitHub.