rodauth-omniauth 0.3.3 → 0.3.4

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: 19c3567386c82344beabaf49bfb59614694fd8fecb212e72583cea29ceed613b
4
- data.tar.gz: 7a6b4e6cac612f61c07e11163e98be55ff0d4ab0d0a7815f2a156c0a4bc51577
3
+ metadata.gz: 294ad80d69ff7fd5fef2a1b2722ca716ae205df852a9398efc423ad350eb7e33
4
+ data.tar.gz: 7b5d75a069904a4a8780114c9eed4e03a8aa9c1533addfa458c91f77f9568cf8
5
5
  SHA512:
6
- metadata.gz: bf3cb6c85645361488496d881dc10f35b09ea088a22b340264b7a1b5d42009af0b08f9783e850e04fffcaf2541685755d8cb6fa87ce2c8202016c2478a7e4c61
7
- data.tar.gz: ebb120c5a3c61935f8c230f9418f977fafeb693af0180805d1103c22d93308dc763253f476575c5b48b2dee157fef30b500443a8f8becfe23b78e665c92e0984
6
+ metadata.gz: d4765fceb95ccd2808bf1d208d43cf42030b447688768017cb80f480b6e1a6302c382a4e47ce47cba75af03577f5904020529ad36a67355d919ba9252abe0186
7
+ data.tar.gz: 2c10c017f1bf7fd6813bf7d7aba71f3aa7975cd11e130308a804624441ef8119ca8dbc2a85095e9e9d668cb787b281ee150db4cf8768cdba04613d34cdf3d972
data/README.md CHANGED
@@ -71,11 +71,18 @@ You can now add authentication links to your login form:
71
71
  Assuming you configured the providers correctly, you should now be able to authenticate via an external provider. The `omniauth` feature handles the callback request, automatically creating new identities and verified accounts from those identities as needed.
72
72
 
73
73
  ```rb
74
- DB[:accounts].all
75
- #=> [{ id: 123, status_id: 2, email: "user@example.com" }]
76
- DB[:account_identities].all
77
- #=> [{ id: 456, account_id: 123, provider: "facebook", uid: "984346198764" },
78
- # { id: 789, account_id: 123, provider: "google", uid: "5871623487134"}]
74
+ Account.all
75
+ #=> [#<Account @values={ id: 123, status_id: 2, email: "user@example.com" }>]
76
+ Account::Identity.all
77
+ #=> [#<Account::Identity @values={ id: 456, account_id: 123, provider: "facebook", uid: "984346198764" }>,
78
+ # #<Account::Identity @values={ id: 789, account_id: 123, provider: "google", uid: "5871623487134"}>]
79
+ ```
80
+
81
+ The example above assumes you're using [rodauth-model] (automatically setup with [rodauth-rails]), which will define `Account::Identity` model for the `account_identities` table, along with the `identities` association on the `Account` model.
82
+
83
+ ```rb
84
+ account = Account.first
85
+ account.identities #=> [#<Account::Identity ...>, ...]
79
86
  ```
80
87
 
81
88
  Currently, provider login is required to return the user's email address, and account creation is assumed not to require additional fields that need to be entered manually. There is currently also no built-in functionality for connecting/removing external identities when signed in. Both features are planned for future versions.
@@ -166,25 +173,6 @@ omniauth_identities_provider_column :provider
166
173
  omniauth_identities_uid_column :uid
167
174
  ```
168
175
 
169
- ### Model associations
170
-
171
- When using the [rodauth-model] gem, an `identities` one-to-many association will be defined on the account model:
172
-
173
- ```rb
174
- require "rodauth/model"
175
-
176
- class Account < Sequel::Model
177
- include Rodauth::Model(RodauthApp.rodauth)
178
- end
179
- ```
180
- ```rb
181
- Account.first.identities #=>
182
- # [
183
- # #<Account::Identity id=123 provider="facebook" uid="987434628">,
184
- # #<Account::Identity id=456 provider="google" uid="274673644">
185
- # ]
186
- ```
187
-
188
176
  ## Base
189
177
 
190
178
  The `omniauth` feature builds on top of the `omniauth_base` feature, which sets up OmniAuth and routes its requests, but has no interaction with the database. So, if you would prefer to handle external logins differently, you can load just the `omniauth_base` feature, and implement your own callback phase.
@@ -422,4 +410,5 @@ Everyone interacting in the rodauth-omniauth project's codebases, issue trackers
422
410
  [Rodauth]: https://github.com/jeremyevans/rodauth
423
411
  [OmniAuth]: https://github.com/omniauth/omniauth
424
412
  [rodauth-model]: https://github.com/janko/rodauth-model
413
+ [rodauth-rails]: https://github.com/janko/rodauth-rails
425
414
  [omniauth-oauth2]: https://github.com/omniauth/omniauth-oauth2
@@ -166,12 +166,13 @@ module Rodauth
166
166
  # Makes OmniAuth strategies use the JWT session hash.
167
167
  def set_omniauth_jwt_session
168
168
  rack_session = request.env["rack.session"]
169
- session.keys.each { |k| session[k.to_s] = session.delete(k) } unless scope.opts[:sessions_convert_symbols]
169
+ session.transform_keys!(&:to_s) unless scope.opts[:sessions_convert_symbols]
170
170
  request.env["rack.session"] = session
171
171
  yield
172
172
  ensure
173
- session.keys.each { |k| session[k.to_sym] = session.delete(k) } unless scope.opts[:sessions_convert_symbols]
174
- request.env["rack.session"] = rack_session
173
+ session.transform_keys!(&:to_sym) unless scope.opts[:sessions_convert_symbols]
174
+ request.env.delete("rack.session")
175
+ request.env["rack.session"] = rack_session if rack_session
175
176
  end
176
177
 
177
178
  # Makes the Rodauth instance accessible inside OmniAuth strategies
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "rodauth-omniauth"
3
- spec.version = "0.3.3"
3
+ spec.version = "0.3.4"
4
4
  spec.authors = ["Janko Marohnić"]
5
5
  spec.email = ["janko@hey.com"]
6
6
 
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.homepage = "https://github.com/janko/rodauth-omniauth"
10
10
  spec.license = "MIT"
11
11
 
12
- spec.required_ruby_version = ">= 2.3"
12
+ spec.required_ruby_version = ">= 2.5"
13
13
 
14
14
  spec.metadata["homepage_uri"] = spec.homepage
15
15
  spec.metadata["source_code_uri"] = spec.homepage
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rodauth-omniauth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janko Marohnić
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-14 00:00:00.000000000 Z
11
+ date: 2024-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rodauth
@@ -205,14 +205,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
205
205
  requirements:
206
206
  - - ">="
207
207
  - !ruby/object:Gem::Version
208
- version: '2.3'
208
+ version: '2.5'
209
209
  required_rubygems_version: !ruby/object:Gem::Requirement
210
210
  requirements:
211
211
  - - ">="
212
212
  - !ruby/object:Gem::Version
213
213
  version: '0'
214
214
  requirements: []
215
- rubygems_version: 3.4.7
215
+ rubygems_version: 3.5.3
216
216
  signing_key:
217
217
  specification_version: 4
218
218
  summary: Rodauth extension for logging in and creating account via OmniAuth authentication.