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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 804b5951b903f5f1523f6fd2ca0589afe8833c3e27f0bb3cb7770ee31a111510
4
- data.tar.gz: 646bca80b7c4da2ec1db963463fd335c2fe8610c55b381d69b3d755394945df3
3
+ metadata.gz: 70df4bc301aecf7787f230307e05d94a5df5e68bc53c631bd4923e007f1c4882
4
+ data.tar.gz: e19b1250fed256fd761c47b08d7b436311547559834b6939202d0bf2b4d35f92
5
5
  SHA512:
6
- metadata.gz: dea2e9f53bc53f5b7c55233501f42fa5d4dfe99eb5545cb66d1cda0f3b0529159916949fbdbcc76abd6e409898bf26c7b9ea38de042b8183281994991fd5813a
7
- data.tar.gz: 65681836df17eb8e877ae751dca740a1049f42f5f52f75c42a1c75ed0db1bd9c5d68c35410ab28596ca1e4e2b71d2602c11a7836dedfd71bf095768508694d27
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 = :test
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.
@@ -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
- self.configuration ||= Configuration.new
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 = nil
41
+ @client_name = original_client_name
38
42
  end
39
43
 
40
44
  def with_auth(options_or_access_token, &block)
@@ -1,5 +1,5 @@
1
1
  module Zaikio
2
2
  module OAuthClient
3
- VERSION = "0.3.6".freeze
3
+ VERSION = "0.3.7".freeze
4
4
  end
5
5
  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.3.6
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-04-29 00:00:00.000000000 Z
11
+ date: 2020-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails