zaikio-oauth_client 0.10.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -0
- data/app/controllers/zaikio/oauth_client/subscriptions_controller.rb +2 -0
- data/config/locales/de.yml +4 -0
- data/config/locales/en.yml +2 -1
- data/lib/zaikio/oauth_client.rb +1 -0
- data/lib/zaikio/oauth_client/authenticatable.rb +28 -0
- data/lib/zaikio/oauth_client/error.rb +5 -0
- data/lib/zaikio/oauth_client/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3caeb6fd8b46df684ae2ead61a41965d33d0c8447576ca3dd4472e035917732
|
4
|
+
data.tar.gz: 7efeeb1977f82515ac60e41dfeec76a2e03867cead09e4e7bdee225f9e2d7051
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49c66d7cee9b78180b46f5f75318e9cdab0e0ea04cf7bf349c09990ac337dc367e32fcf15f70a3728fa524a53ea3a5771e0c436b9902d4f7a023ad72a0b21adb
|
7
|
+
data.tar.gz: b82883c6b3b85dabe9759266bd5c5f4b338bb9917c3bd60696412e4651a23c45e73e296a600258aa7072ad5c417dd728742afecdba8a5f14b66a673ff836e0f4
|
data/README.md
CHANGED
@@ -3,6 +3,8 @@ module Zaikio
|
|
3
3
|
class SubscriptionsController < ConnectionsController
|
4
4
|
def new
|
5
5
|
opts = params.permit(:client_name, :state, :plan, :organization_id)
|
6
|
+
opts[:redirect_with_error] = 1
|
7
|
+
opts[:state] ||= cookies.encrypted[:state] = SecureRandom.urlsafe_base64(32)
|
6
8
|
|
7
9
|
plan = opts.delete(:plan)
|
8
10
|
organization_id = opts.delete(:organization_id)
|
data/config/locales/en.yml
CHANGED
data/lib/zaikio/oauth_client.rb
CHANGED
@@ -5,7 +5,9 @@ module Zaikio
|
|
5
5
|
|
6
6
|
def new
|
7
7
|
opts = params.permit(:client_name, :show_signup, :force_login, :state)
|
8
|
+
opts[:redirect_with_error] = 1
|
8
9
|
client_name = opts.delete(:client_name)
|
10
|
+
opts[:state] ||= cookies.encrypted[:state] = SecureRandom.urlsafe_base64(32)
|
9
11
|
|
10
12
|
redirect_to oauth_client.auth_code.authorize_url(
|
11
13
|
redirect_uri: approve_url(client_name),
|
@@ -15,6 +17,21 @@ module Zaikio
|
|
15
17
|
end
|
16
18
|
|
17
19
|
def approve
|
20
|
+
if params[:error].present?
|
21
|
+
redirect_to send(
|
22
|
+
respond_to?(:error_path_for) ? :error_path_for : :default_error_path_for,
|
23
|
+
params[:error],
|
24
|
+
description: params[:error_description]
|
25
|
+
) and return
|
26
|
+
end
|
27
|
+
|
28
|
+
if cookies.encrypted[:state].present? && params[:state] != cookies.encrypted[:state]
|
29
|
+
return redirect_to send(
|
30
|
+
respond_to?(:error_path_for) ? :error_path_for : :default_error_path_for,
|
31
|
+
"invalid_state"
|
32
|
+
)
|
33
|
+
end
|
34
|
+
|
18
35
|
access_token = create_access_token
|
19
36
|
|
20
37
|
origin = cookies.encrypted[:origin]
|
@@ -31,6 +48,7 @@ module Zaikio
|
|
31
48
|
def destroy
|
32
49
|
access_token_id = cookies.encrypted[:zaikio_access_token_id]
|
33
50
|
cookies.delete :zaikio_access_token_id
|
51
|
+
cookies.delete :state
|
34
52
|
|
35
53
|
redirect_to send(
|
36
54
|
respond_to?(:after_destroy_path_for) ? :after_destroy_path_for : :default_after_destroy_path_for,
|
@@ -87,6 +105,16 @@ module Zaikio
|
|
87
105
|
|
88
106
|
main_app.root_path
|
89
107
|
end
|
108
|
+
|
109
|
+
def default_error_path_for(error_code, description: nil)
|
110
|
+
raise Zaikio::OAuthClient::InvalidScopesError, description if error_code == "invalid_scope"
|
111
|
+
|
112
|
+
unless error_code == "access_denied"
|
113
|
+
flash[:alert] = I18n.t("zaikio.oauth_client.error_occured", error: error_code, description: description)
|
114
|
+
end
|
115
|
+
|
116
|
+
main_app.root_path
|
117
|
+
end
|
90
118
|
end
|
91
119
|
end
|
92
120
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zaikio-oauth_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zaikio GmbH
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-04-
|
11
|
+
date: 2021-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -150,6 +150,7 @@ files:
|
|
150
150
|
- app/jobs/zaikio/cleanup_access_tokens_job.rb
|
151
151
|
- app/models/zaikio/access_token.rb
|
152
152
|
- config/initializers/inflections.rb
|
153
|
+
- config/locales/de.yml
|
153
154
|
- config/locales/en.yml
|
154
155
|
- config/routes.rb
|
155
156
|
- db/migrate/20190426155505_enable_postgres_extensions_for_uuids.rb
|
@@ -162,6 +163,7 @@ files:
|
|
162
163
|
- lib/zaikio/oauth_client/client_configuration.rb
|
163
164
|
- lib/zaikio/oauth_client/configuration.rb
|
164
165
|
- lib/zaikio/oauth_client/engine.rb
|
166
|
+
- lib/zaikio/oauth_client/error.rb
|
165
167
|
- lib/zaikio/oauth_client/test_helper.rb
|
166
168
|
- lib/zaikio/oauth_client/version.rb
|
167
169
|
homepage: https://github.com/zaikio/zaikio-oauth_client
|