zaikio-oauth_client 0.4.2 → 0.6.0

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: eb774c96ee88f324e6da5b8ece141a110f306d5a38506ab33bb1c44b4fa6ca16
4
- data.tar.gz: 6bf71d03fac23bca3c96fe38c7b7ad84d0f609dc98a4cc673ab44e83dfff001f
3
+ metadata.gz: 70305a5016ca591d7275d6bf09627865e32417481047c3717099108c251a5d93
4
+ data.tar.gz: 8274f9034a133d510be6fc6c42e6fb7c96e807fbac4b076ce0f42f13da7b2536
5
5
  SHA512:
6
- metadata.gz: 878a92cd495fb07fa942a0e100862586a42c262bafdd9afa64d9cee76efd2b3a85d833b4c92bda916f66afa97c6c7cfe9090ddee2cdf9834a7deae3c22bb0bc3
7
- data.tar.gz: 72084e3c353aeed81b6dbc7cee0eb2ae44ab5140c5a55319dc4933e35944881d66a98fa329230d3a3b902e98701f1dc9de6e05539e9b1f8917720c5056f21a3c
6
+ metadata.gz: 9cae8d8c1dee2d253d38764adcd245ed042017c99bc70255db2f236e11d2c77ef20b75f366a30ca59eda1c1ab9673e54b6e7117b5ab2159d78a6afbc38c214fe
7
+ data.tar.gz: 8cfd8a8df57d6076292ddca2253cb3cd9f79c2411fcadddc265757b5fea67c4dfabb67cd4406459e894708cee9b9d37bf6025cbb3fd455ceb575521cbb3000de
data/README.md CHANGED
@@ -60,7 +60,7 @@ Zaikio::OAuthClient.configure do |config|
60
60
  end
61
61
 
62
62
  config.around_auth do |access_token, block|
63
- Zaikio::Directory.with_token(access_token.token) do
63
+ Zaikio::Hub.with_token(access_token.token) do
64
64
  block.call(access_token)
65
65
  end
66
66
  end
@@ -93,7 +93,7 @@ Configure sidekiq scheduler in `config/sidekiq.yml`:
93
93
 
94
94
  ### OAuth Flow
95
95
 
96
- From any point in your application you can start using the Zaikio Directory OAuth2 flow with
96
+ From any point in your application you can start using the Zaikio Hub OAuth2 flow with
97
97
 
98
98
  ```rb
99
99
  redirect_to zaikio_oauth_client.new_session_path
@@ -109,10 +109,10 @@ This will redirect the user to the OAuth Authorize endpoint of the Zaikio Direct
109
109
 
110
110
  The Zaikio gem engine will set a cookie for the user after a successful OAuth flow: `cookies.encrypted[:zaikio_person_id]`.
111
111
 
112
- If you are using for example `Zaikio::Directory::Models`, you can use this snippet to set the current user:
112
+ If you are using for example `Zaikio::Hub::Models`, you can use this snippet to set the current user:
113
113
 
114
114
  ```ruby
115
- Current.user ||= Zaikio::Directory::Models::Person.find_by(id: cookies.encrypted[:zaikio_person_id])
115
+ Current.user ||= Zaikio::Hub::Models::Person.find_by(id: cookies.encrypted[:zaikio_person_id])
116
116
  ````
117
117
 
118
118
  You can then use `Current.user` anywhere.
@@ -149,7 +149,7 @@ class ApplicationController < ActionController::Base
149
149
  cookies.encrypted[:zaikio_person_id] = access_token.bearer_id unless access_token.organization?
150
150
 
151
151
  # Sync data on login
152
- Zaikio::Directory.with_token(access_token.token) do
152
+ Zaikio::Hub.with_token(access_token.token) do
153
153
  access_token.bearer_klass.find_and_reload!(access_token.bearer_id, includes: :all)
154
154
  end
155
155
 
@@ -234,14 +234,15 @@ If you use the provided OAuth credentials from above and test this against the S
234
234
 
235
235
  **Make sure you have the dummy app running locally to validate your changes.**
236
236
 
237
- Make your changes and adjust `version.rb`. Please make sure to update `CHANGELOG.md`.
238
-
239
- **To push a new release:**
240
-
241
- - `gem build zaikio-oauth_client.gemspec`
242
- - `gem push zaikio-oauth_client-0.1.0.gem`
243
- *Adjust the version accordingly.*
237
+ - Make your changes and submit a pull request for them
238
+ - Make sure to update `CHANGELOG.md`
244
239
 
240
+ To release a new version of the gem:
241
+ - Update the version in `lib/zaikio/oauth_client/version.rb`
242
+ - Update `CHANGELOG.md` to include the new version and its release date
243
+ - Commit and push your changes
244
+ - Create a [new release on GitHub](https://github.com/zaikio/zaikio-directory-models/releases/new)
245
+ - CircleCI will build the Gem package and push it Rubygems for you
245
246
 
246
247
  ## License
247
248
 
@@ -38,13 +38,13 @@ module Zaikio
38
38
  .where("refresh_token IS NOT NULL")
39
39
  .where.not(id: Zaikio::JWTAuth.revoked_token_ids)
40
40
  }
41
- scope :by_bearer, lambda { |bearer_type: "Person", bearer_id:, scopes: []|
41
+ scope :by_bearer, lambda { |bearer_id:, scopes: [], bearer_type: "Person"|
42
42
  where(bearer_type: bearer_type, bearer_id: bearer_id)
43
43
  .where("scopes @> ARRAY[?]::varchar[]", scopes)
44
44
  }
45
45
  scope :usable, lambda { |options|
46
46
  by_bearer(**options).valid.or(by_bearer(**options).valid_refresh)
47
- .order(expires_at: :desc)
47
+ .order(expires_at: :desc)
48
48
  }
49
49
 
50
50
  def expired?
@@ -60,10 +60,10 @@ module Zaikio
60
60
  end
61
61
 
62
62
  def bearer_klass
63
- return unless Zaikio.const_defined?("Directory::Models")
63
+ return unless Zaikio.const_defined?("Hub::Models")
64
64
 
65
- if Zaikio::Directory::Models.configuration.respond_to?(:"#{bearer_type.underscore}_class_name")
66
- Zaikio::Directory::Models.configuration.public_send(:"#{bearer_type.underscore}_class_name").constantize
65
+ if Zaikio::Hub::Models.configuration.respond_to?(:"#{bearer_type.underscore}_class_name")
66
+ Zaikio::Hub::Models.configuration.public_send(:"#{bearer_type.underscore}_class_name").constantize
67
67
  else
68
68
  "Zaikio::#{bearer_type}".constantize
69
69
  end
@@ -0,0 +1,7 @@
1
+ class EnhanceAccessTokenIndex < ActiveRecord::Migration[6.1]
2
+ def change
3
+ remove_index :zaikio_access_tokens, %i[bearer_type bearer_id]
4
+ add_index :zaikio_access_tokens, %i[audience bearer_type bearer_id],
5
+ name: :zaikio_access_tokens_lookup_index
6
+ end
7
+ end
@@ -45,7 +45,7 @@ module Zaikio
45
45
  access_token = if options_or_access_token.is_a?(Zaikio::AccessToken)
46
46
  options_or_access_token
47
47
  else
48
- get_access_token(options_or_access_token)
48
+ get_access_token(**options_or_access_token)
49
49
  end
50
50
 
51
51
  return unless block_given?
@@ -25,7 +25,7 @@ module Zaikio
25
25
  end
26
26
 
27
27
  def logger
28
- @logger ||= Logger.new(STDOUT)
28
+ @logger ||= Logger.new($stdout)
29
29
  end
30
30
 
31
31
  def register_client(name)
@@ -1,5 +1,5 @@
1
1
  module Zaikio
2
2
  module OAuthClient
3
- VERSION = "0.4.2".freeze
3
+ VERSION = "0.6.0".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.4.2
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zaikio GmbH
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-13 00:00:00.000000000 Z
11
+ date: 2021-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -111,6 +111,7 @@ files:
111
111
  - config/routes.rb
112
112
  - db/migrate/20190426155505_enable_postgres_extensions_for_uuids.rb
113
113
  - db/migrate/20191017132048_create_zaikio_access_tokens.rb
114
+ - db/migrate/20210222135920_enhance_access_token_index.rb
114
115
  - lib/tasks/zaikio_tasks.rake
115
116
  - lib/zaikio/oauth_client.rb
116
117
  - lib/zaikio/oauth_client/authenticatable.rb
@@ -119,12 +120,12 @@ files:
119
120
  - lib/zaikio/oauth_client/engine.rb
120
121
  - lib/zaikio/oauth_client/test_helper.rb
121
122
  - lib/zaikio/oauth_client/version.rb
122
- homepage: https://www.zaikio.com
123
+ homepage: https://github.com/zaikio/zaikio-oauth_client
123
124
  licenses:
124
125
  - MIT
125
126
  metadata:
126
127
  changelog_uri: https://github.com/zaikio/zaikio-oauth_client/blob/master/CHANGELOG.md
127
- post_install_message:
128
+ post_install_message:
128
129
  rdoc_options: []
129
130
  require_paths:
130
131
  - lib
@@ -140,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
141
  version: '0'
141
142
  requirements: []
142
143
  rubygems_version: 3.2.3
143
- signing_key:
144
+ signing_key:
144
145
  specification_version: 4
145
146
  summary: Zaikio Platform Connectivity
146
147
  test_files: []