zaikio-oauth_client 0.19.1 → 0.20.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: fd5390d254c886ad8c082def82463c6653bdb91b4f08433bf138b872e9fb54ff
4
- data.tar.gz: b9bca34becf29861bd4e5f57d88492a9dfb7aecb8ad6ed2306c2007ee75740e5
3
+ metadata.gz: 821f98a1795103278c91ca8ab8a1e22696eaafa05359be7cfeca5511efa9f125
4
+ data.tar.gz: d92c6e1f033ae45682192875f95a4021ce47489d5ec97fd53d4d8d725ad8344c
5
5
  SHA512:
6
- metadata.gz: 61f6e1657014daa3b0cc5efb2e5a0ac97c0d81708d68ad7a98b030e24ce5fd2e3918c2613371dc7f9ed64f5546dad84e8f189e996fe1db113a5a295137cba74c
7
- data.tar.gz: 38e9e845d6bae276a28ef32d6fab275ae0539598c1f7c85680ba87554e3ac0f5619261cb9346435b787c06526d0a87ca2ddfbb502a299027d1b81ea75bc424af
6
+ metadata.gz: 6932c3a87827582e28c55540af6db76066e14fc61152ad4e50245ed916792a71545ebd40d9882c62ca6713bb40e3e7bfe4201c22fad5d364b9b8e1d61bcda640
7
+ data.tar.gz: 203fda493a173f5619eb32e536624848fcbd39623d35db5243c79bdbdfb3664b109b72bde6a1ee069ff1446a07931784a620588b641c9c8996aafee2d32441f7
@@ -1,11 +1,13 @@
1
1
  module Zaikio
2
2
  module OAuthClient
3
- module Authenticatable
3
+ module Authenticatable # rubocop:disable Metrics/ModuleLength
4
4
  extend ActiveSupport::Concern
5
5
 
6
6
  def new
7
7
  opts = params.permit(:client_name, :show_signup, :prompt, :prompt_email_confirmation,
8
- :force_login, :state, :lang)
8
+ :force_login, :state, :lang,
9
+ person: %i[first_name name email],
10
+ organization: [:name, :country_code, { kinds: [] }])
9
11
  opts[:lang] ||= I18n.locale if defined?(I18n)
10
12
  client_name = opts.delete(:client_name)
11
13
  opts[:state] ||= session[:state] = SecureRandom.urlsafe_base64(32)
@@ -3,7 +3,7 @@ module Zaikio
3
3
  module TestHelper
4
4
  extend ActiveSupport::Concern
5
5
 
6
- VirtualAccessToken = Struct.new(:bearer_id, :bearer_type, :audience, :expired?, keyword_init: true)
6
+ VirtualAccessToken = Struct.new(:id, :bearer_id, :bearer_type, :audience, :expired?, keyword_init: true)
7
7
 
8
8
  class << self
9
9
  def find_active_access_token(id)
@@ -12,6 +12,7 @@ module Zaikio
12
12
  _, audience, person_id = id.split(":")
13
13
 
14
14
  VirtualAccessToken.new(
15
+ id: id,
15
16
  bearer_id: person_id,
16
17
  audience: audience,
17
18
  bearer_type: "Person",
@@ -1,5 +1,5 @@
1
1
  module Zaikio
2
2
  module OAuthClient
3
- VERSION = "0.19.1".freeze
3
+ VERSION = "0.20.0".freeze
4
4
  end
5
5
  end
@@ -80,7 +80,7 @@ module Zaikio
80
80
 
81
81
  # This method can be used to find an active access token by id.
82
82
  # It might refresh the access token to get an active one.
83
- def find_active_access_token(id)
83
+ def find_active_access_token(id, valid_for: 30.seconds)
84
84
  return unless id
85
85
 
86
86
  if Rails.env.test?
@@ -88,7 +88,9 @@ module Zaikio
88
88
  return access_token if access_token
89
89
  end
90
90
 
91
- access_token = Zaikio::AccessToken.find_by(id: id)
91
+ access_token = Zaikio::AccessToken.valid(valid_for.from_now).or(
92
+ Zaikio::AccessToken.valid_refresh(valid_for.from_now)
93
+ ).find_by(id: id)
92
94
  access_token = access_token.refresh! if access_token&.expired?
93
95
 
94
96
  access_token
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.19.1
4
+ version: 0.20.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: 2022-08-03 00:00:00.000000000 Z
11
+ date: 2022-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack