gamora 0.3.0 → 0.4.0

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: f764dd52b539d07ab42bc00f6eb1883c678ac791ff0eb7f9edc69f959b1df71d
4
- data.tar.gz: f67a0f3128c9728e81d67df2fd18c1c8893a4c18902b4f869ae41f3cb2e7050f
3
+ metadata.gz: f5603bf759444fee16ea4536a746c0aa1b215cc3c07f3e9405513605febeebe6
4
+ data.tar.gz: dba68b8d99573682f59dcc8705594fd698f5bd8e102009864123d56e57fc1ca6
5
5
  SHA512:
6
- metadata.gz: 0f6b7b02f44aede21fb839c0fd4fd2ece348a0c32c30da203ea4941dbe17ae5501b54fa95d379b00c4b39f3adfa8d68ea1fd3b4160d99f19411f614fdfaa6629
7
- data.tar.gz: b13d5205e38e4ebc25a5e82c183a5a37f499368cc5f067227efc64a11eb468a9b1ef8dfee8421bd02c1901bfc9c6238a69816b7cf9db8fbf04a85d7eeb910d75
6
+ metadata.gz: 30b06a7d4dfa731b547f9615dbf24082a07e64312db427477768117bf0ec2668901ae3a9905a10abd1ceef827f78d7da1c34f618da7e9c64bc021cc73fb1dc63
7
+ data.tar.gz: c14b734316cbd4a67487744f265684732048443f02112d3361772f44efd8446e4cb73cf95b5ca01fb904a1bb505e2b0c8e2b3d7c72e6902f6f65a7e95f68a7eb
@@ -0,0 +1,37 @@
1
+ module Gamora
2
+ module AuthorizationUrl
3
+ def authorization_url(params, extra_params = {})
4
+ default_params = {
5
+ scope: Configuration.default_scope,
6
+ theme: Configuration.default_theme,
7
+ prompt: Configuration.default_prompt,
8
+ strategy: Configuration.default_strategy,
9
+ branding: Configuration.default_branding,
10
+ ui_locales: Configuration.ui_locales.call
11
+ }
12
+
13
+ data =
14
+ default_params.
15
+ merge(extra_params).
16
+ merge(authorization_params(params)).
17
+ compact_blank
18
+
19
+ Client.from_config.auth_code.authorize_url(data)
20
+ end
21
+
22
+ private
23
+
24
+ def authorization_params(params)
25
+ params.permit(
26
+ :scope,
27
+ :state,
28
+ :theme,
29
+ :prompt,
30
+ :max_age,
31
+ :strategy,
32
+ :branding,
33
+ :ui_locales
34
+ )
35
+ end
36
+ end
37
+ end
@@ -2,34 +2,12 @@
2
2
 
3
3
  module Gamora
4
4
  class AuthenticationController < ApplicationController
5
- def show
6
- redirect_to authorization_url, allow_other_host: true
7
- end
8
-
9
- private
5
+ include AuthorizationUrl
10
6
 
11
- def authorization_url
12
- Client.from_config.auth_code.authorize_url({
13
- scope: Configuration.default_scope,
14
- theme: Configuration.default_theme,
15
- prompt: Configuration.default_prompt,
16
- strategy: Configuration.default_strategy,
17
- branding: Configuration.default_branding,
18
- ui_locales: Configuration.ui_locales.call
19
- }.merge(authorization_params).compact_blank)
20
- end
21
-
22
- def authorization_params
23
- params.permit(
24
- :scope,
25
- :state,
26
- :theme,
27
- :prompt,
28
- :max_age,
29
- :strategy,
30
- :branding,
31
- :ui_locales
32
- )
7
+ def show
8
+ redirect_to authorization_url(params),
9
+ allow_other_host: true,
10
+ status: :see_other
33
11
  end
34
12
  end
35
13
  end
@@ -7,6 +7,7 @@ module Gamora
7
7
  session[:access_token] = access_token.token
8
8
  session[:refresh_token] = access_token.refresh_token
9
9
  redirect_to session.delete("gamora.origin") || main_app.root_path
10
+
10
11
  rescue OAuth2::Error
11
12
  render plain: "Invalid authorization code"
12
13
  end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Gamora
4
+ class UnauthenticationController < ApplicationController
5
+ include AuthorizationUrl
6
+
7
+ def show
8
+ session[:access_token] = nil
9
+ session[:refresh_token] = nil
10
+
11
+ redirect_to authorization_url(params, { max_age: 0 }),
12
+ allow_other_host: true,
13
+ status: :see_other
14
+ end
15
+ end
16
+ end
data/config/routes.rb CHANGED
@@ -2,5 +2,6 @@
2
2
 
3
3
  Gamora::Engine.routes.draw do
4
4
  get "amco", to: "authentication#show", as: :authentication
5
+ get "logout", to: "unauthentication#show", as: :logout
5
6
  get "amco/callback", to: "callback#show", as: :callback
6
7
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Gamora
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gamora
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alejandro Gutiérrez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-04 00:00:00.000000000 Z
11
+ date: 2022-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oauth2
@@ -49,9 +49,11 @@ files:
49
49
  - MIT-LICENSE
50
50
  - README.md
51
51
  - Rakefile
52
+ - app/controllers/concerns/gamora/authorization_url.rb
52
53
  - app/controllers/gamora/application_controller.rb
53
54
  - app/controllers/gamora/authentication_controller.rb
54
55
  - app/controllers/gamora/callback_controller.rb
56
+ - app/controllers/gamora/unauthentication_controller.rb
55
57
  - app/models/gamora/application_record.rb
56
58
  - config/routes.rb
57
59
  - lib/gamora.rb