gamora 0.4.0 → 0.5.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: f5603bf759444fee16ea4536a746c0aa1b215cc3c07f3e9405513605febeebe6
4
- data.tar.gz: dba68b8d99573682f59dcc8705594fd698f5bd8e102009864123d56e57fc1ca6
3
+ metadata.gz: 563e700187ac79aef45f7d11aad774aee205f7917870f5431d3f1d6d63d7850b
4
+ data.tar.gz: 9817af7d6c4eb85abb6bdaa76d53efc0f1016f6516df95c674366b89ab920b49
5
5
  SHA512:
6
- metadata.gz: 30b06a7d4dfa731b547f9615dbf24082a07e64312db427477768117bf0ec2668901ae3a9905a10abd1ceef827f78d7da1c34f618da7e9c64bc021cc73fb1dc63
7
- data.tar.gz: c14b734316cbd4a67487744f265684732048443f02112d3361772f44efd8446e4cb73cf95b5ca01fb904a1bb505e2b0c8e2b3d7c72e6902f6f65a7e95f68a7eb
6
+ metadata.gz: 34de3119b475580ec5b65cab413d8f6ca7aed17fe433542ea81c6ef5ba314a67d9a29c384dd2aaafc9a9ff267510efbf6649a33f43fb7d41a15a0d3b7c308661
7
+ data.tar.gz: 2848933923aee39b310b107e77c6ec219b6642f0bda21c0e61677fbf056f3f80629f0d9bed0dbb81ea2637483d333de77292a871d86a358f19d98e1bade10b69
@@ -47,12 +47,26 @@ module Gamora
47
47
 
48
48
  def resource_owner_claims(access_token)
49
49
  return {} if access_token.blank?
50
- oauth_client.userinfo(access_token)
50
+ resource_owner_claims!(access_token)
51
+ end
52
+
53
+ def resource_owner_claims!(access_token)
54
+ Rails.cache.fetch(cache_key(access_token), cache_options) do
55
+ oauth_client.userinfo(access_token)
56
+ end
51
57
  end
52
58
 
53
59
  def oauth_client
54
60
  Client.from_config
55
61
  end
62
+
63
+ def cache_options
64
+ { expires_in: Configuration.userinfo_cache_expires_in }
65
+ end
66
+
67
+ def cache_key(access_token)
68
+ "userinfo:#{Digest::SHA256.hexdigest(access_token)}"
69
+ end
56
70
  end
57
71
  end
58
72
  end
@@ -16,6 +16,7 @@ module Gamora
16
16
  mattr_accessor :default_branding, default: "amco"
17
17
  mattr_accessor :default_theme, default: "default"
18
18
  mattr_accessor :ui_locales, default: -> { I18n.locale }
19
+ mattr_accessor :userinfo_cache_expires_in, default: 0.seconds
19
20
 
20
21
  def setup
21
22
  yield(self) if block_given?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Gamora
4
- VERSION = "0.4.0"
4
+ VERSION = "0.5.0"
5
5
  end
@@ -18,4 +18,5 @@ Gamora.setup do |config|
18
18
  # config.default_branding = "amco"
19
19
  # config.default_theme = "default"
20
20
  # config.ui_locales = -> { I18n.locale }
21
+ # config.userinfo_cache_expires_in = 0.seconds
21
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gamora
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alejandro Gutiérrez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-02 00:00:00.000000000 Z
11
+ date: 2022-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oauth2