zaikio-oauth_client 0.3.6 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -1
- data/lib/zaikio/oauth_client.rb +7 -3
- data/lib/zaikio/oauth_client/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70df4bc301aecf7787f230307e05d94a5df5e68bc53c631bd4923e007f1c4882
|
4
|
+
data.tar.gz: e19b1250fed256fd761c47b08d7b436311547559834b6939202d0bf2b4d35f92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 621cbc8f24b5db20feebc5398cba2a444cab5a2d9652e44ed53675b889b7033df68410302885781aa7714626ed3f325384e9f6ca80fd21025b2490f6310d4060
|
7
|
+
data.tar.gz: 728955826c11c5f9d955ad03f1d2c3d9631f023d07aa84fbe9f06583392fb87a9d5850e3195381100aacf4262d94dec725018e3aa9783e862a5a546486aa7ae5
|
data/README.md
CHANGED
@@ -35,7 +35,7 @@ mount Zaikio::OAuthClient::Engine => "/zaikio"
|
|
35
35
|
```rb
|
36
36
|
# config/initializers/zaikio_oauth_client.rb
|
37
37
|
Zaikio::OAuthClient.configure do |config|
|
38
|
-
config.environment = :
|
38
|
+
config.environment = :sandbox
|
39
39
|
|
40
40
|
config.register_client :warehouse do |warehouse|
|
41
41
|
warehouse.client_id = "52022d7a-7ba2-41ed-8890-97d88e6472f6"
|
@@ -95,6 +95,24 @@ You can then use `Current.user` anywhere.
|
|
95
95
|
|
96
96
|
For **logout** use: `zaikio_oauth_client.session_path, method: :delete` or build your own controller for deleting the cookie.
|
97
97
|
|
98
|
+
#### Multiple clients
|
99
|
+
|
100
|
+
When performing requests against directory APIs, it is important to always provide the correct client in order to use the client credentials flow correctly. Otherwise always the first client will be used. It is recommended to specify an `around_action`:
|
101
|
+
|
102
|
+
```rb
|
103
|
+
class ApplicationController < ActionController::Base
|
104
|
+
around_action :with_client
|
105
|
+
|
106
|
+
private
|
107
|
+
|
108
|
+
def with_client
|
109
|
+
Zaikio::OAuthClient.with_client Current.client_name do
|
110
|
+
yield
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
```
|
115
|
+
|
98
116
|
#### Redirecting
|
99
117
|
|
100
118
|
The `zaikio_oauth_client.new_session_path` which was used for the first initiation of the OAuth flow, accepts an optional parameter `origin` which will then be used to redirect the user at the end of a completed & successful OAuth flow.
|
data/lib/zaikio/oauth_client.rb
CHANGED
@@ -7,14 +7,17 @@ require "zaikio/oauth_client/authenticatable"
|
|
7
7
|
module Zaikio
|
8
8
|
module OAuthClient
|
9
9
|
class << self
|
10
|
-
attr_accessor :configuration
|
11
10
|
attr_reader :client_name
|
12
11
|
|
13
12
|
def configure
|
14
|
-
|
13
|
+
@configuration ||= Configuration.new
|
15
14
|
yield(configuration)
|
16
15
|
end
|
17
16
|
|
17
|
+
def configuration
|
18
|
+
@configuration ||= Configuration.new
|
19
|
+
end
|
20
|
+
|
18
21
|
def for(client_name = nil)
|
19
22
|
client_config_for(client_name).oauth_client
|
20
23
|
end
|
@@ -31,10 +34,11 @@ module Zaikio
|
|
31
34
|
end
|
32
35
|
|
33
36
|
def with_client(client_name)
|
37
|
+
original_client_name = @client_name || nil
|
34
38
|
@client_name = client_name
|
35
39
|
yield
|
36
40
|
ensure
|
37
|
-
@client_name =
|
41
|
+
@client_name = original_client_name
|
38
42
|
end
|
39
43
|
|
40
44
|
def with_auth(options_or_access_token, &block)
|
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.3.
|
4
|
+
version: 0.3.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zaikio GmbH
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|