gamora 0.4.0 → 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: f5603bf759444fee16ea4536a746c0aa1b215cc3c07f3e9405513605febeebe6
4
- data.tar.gz: dba68b8d99573682f59dcc8705594fd698f5bd8e102009864123d56e57fc1ca6
3
+ metadata.gz: dac3585239f26c73703bedba78b8fb157fcae96e795606833510820dcc541635
4
+ data.tar.gz: b12bd007f45d5b97861254c0e7418faa14554eadc31fc0b7fa196932abb8915d
5
5
  SHA512:
6
- metadata.gz: 30b06a7d4dfa731b547f9615dbf24082a07e64312db427477768117bf0ec2668901ae3a9905a10abd1ceef827f78d7da1c34f618da7e9c64bc021cc73fb1dc63
7
- data.tar.gz: c14b734316cbd4a67487744f265684732048443f02112d3361772f44efd8446e4cb73cf95b5ca01fb904a1bb505e2b0c8e2b3d7c72e6902f6f65a7e95f68a7eb
6
+ metadata.gz: 4b824e97d834065f0beb2d0a6d30d343f02edb70d1cecbc7bcd598166474a32e71849b45e46289745ce2d279166a810ed9572cfe6688e48c0e6a9f496cb7e6dd
7
+ data.tar.gz: 6fd882d104aa35374d94e40f1b98b9dc708e26689da28ec9a0736ad4f7b7cba6bf177ecc18ddc8e0c8c5303a087404ec95ead3a20cf8cc2405be0eb49128594b
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Alejandro Gutiérrez
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -80,8 +80,32 @@ Optionally, if you want to do something different when authentication
80
80
  fails, you just need to override the `user_authentication_failed!`
81
81
  method in you controller and customize it as you wish.
82
82
 
83
+ ## Development
84
+
85
+ After checking out the repo, run `bin/setup` to install dependencies. Then,
86
+ run `rake spec` to run the tests. You can also run `bin/console` for an
87
+ interactive prompt that will allow you to experiment.
88
+
89
+ To install this gem onto your local machine, run `bundle exec rake install`.
90
+ To release a new version, update the version number in `version.rb`, and
91
+ then run `bundle exec rake release`, which will create a git tag for the
92
+ version, push git commits and the created tag, and push the `.gem` file
93
+ to [rubygems.org](https://rubygems.org).
94
+
83
95
  ## Contributing
84
- Contribution directions go here.
96
+
97
+ Bug reports and pull requests are welcome on GitHub at https://github.com/amco/gamora-rb.
98
+ This project is intended to be a safe, welcoming space for collaboration, and
99
+ contributors are expected to adhere to the
100
+ [code of conduct](https://github.com/amco/gamora-rb/blob/main/CODE_OF_CONDUCT.md).
85
101
 
86
102
  ## License
87
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
103
+
104
+ The gem is available as open source under the terms of the
105
+ [MIT License](https://opensource.org/licenses/MIT).
106
+
107
+ ## Code of Conduct
108
+
109
+ Everyone interacting in the Gamora project's codebases, issue trackers,
110
+ chat rooms and mailing lists is expected to follow the
111
+ [code of conduct](https://github.com/amco/gamora-rb/blob/main/CODE_OF_CONDUCT.md).
@@ -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.6.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,27 +1,27 @@
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.6.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: 2023-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oauth2
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.4'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.4'
27
27
  - !ruby/object:Gem::Dependency
@@ -46,7 +46,7 @@ executables: []
46
46
  extensions: []
47
47
  extra_rdoc_files: []
48
48
  files:
49
- - MIT-LICENSE
49
+ - LICENSE.txt
50
50
  - README.md
51
51
  - Rakefile
52
52
  - app/controllers/concerns/gamora/authorization_url.rb
@@ -68,13 +68,13 @@ files:
68
68
  - lib/generators/gamora/install_generator.rb
69
69
  - lib/generators/gamora/templates/gamora.rb
70
70
  - lib/tasks/gamora_tasks.rake
71
- homepage: https://github.com/amco/gamora_rb
71
+ homepage: https://github.com/amco/gamora-rb
72
72
  licenses:
73
73
  - MIT
74
74
  metadata:
75
- homepage_uri: https://github.com/amco/gamora_rb
76
- source_code_uri: https://github.com/amco/gamora_rb
77
- changelog_uri: https://github.com/amco/gamora_rb/blob/master/CHANGELOG.md
75
+ homepage_uri: https://github.com/amco/gamora-rb
76
+ source_code_uri: https://github.com/amco/gamora-rb
77
+ changelog_uri: https://github.com/amco/gamora-rb/blob/main/CHANGELOG.md
78
78
  rubygems_mfa_required: 'true'
79
79
  post_install_message:
80
80
  rdoc_options: []
data/MIT-LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright 2022 Alejandro Gutiérrez
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.