rodauth-omniauth 0.3.0 → 0.3.2

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: b983cad17d20d291428c75e8efd5d59b313e83ac68f7998d7d1ec6c508db0ac4
4
- data.tar.gz: e5db5f29f5d2897312d9dc4eca1cc34718ff56bd024bf2f79473a230a9e3cfbc
3
+ metadata.gz: c6cc26306c21226fb3b6f07fcc3bfcc6390160f78aa0c8cbf87ff3e3b1fd2fd4
4
+ data.tar.gz: 9f3d0493b66cdb851e1b8af0e1d85e57544fcdaa6504509072a4edfdcde24d5f
5
5
  SHA512:
6
- metadata.gz: d371d95667924f9e6ea1da68ab3e59471d794230de35eefa7d816edba211c734c981e1ef8ce724987cf58e0e10bf52773bad671dbb352dbbcd6b2762725bba1d
7
- data.tar.gz: 78feadd9466089523ec85e021c980fc90af051c92d6c981e04476888546524f4bcd010321bd89d0f5a4f788c68221ac87dfa6112ea97e67074c9c3ca532daadd
6
+ metadata.gz: c10572574a109db2a9d28ea84239154f7c380b23d4f48f543c3084ae6528c5b2878ed98adab2c9d489ced01ca106cd354b7f5dfa177e496b048c744082ddeb31
7
+ data.tar.gz: 60cf2d25aa82ccb6a6a9f69c01fca040912df718d952a7ad830e443b89589a11d9855d042298c34c1220548b1a4a3eb96252e992de0d8214b1e43f0f4add08f4
data/README.md CHANGED
@@ -43,7 +43,7 @@ end
43
43
  Then enable the `omniauth` feature and register providers in your Rodauth configuration:
44
44
 
45
45
  ```sh
46
- $ bundle add omniauth-facebook omniauth-twitter, omniauth-google_oauth2
46
+ $ bundle add omniauth-facebook omniauth-twitter, omniauth-google-oauth2
47
47
  ```
48
48
  ```rb
49
49
  plugin :rodauth do
@@ -55,6 +55,8 @@ plugin :rodauth do
55
55
  end
56
56
  ```
57
57
 
58
+ It is important to note that `rodauth-omniauth` requires OmniAuth 2.x, and as such, is only compatible with omniauth gems that use the same.
59
+
58
60
  You can now add authentication links to your login form:
59
61
 
60
62
  ```erb
@@ -185,14 +187,14 @@ Account.first.identities #=>
185
187
 
186
188
  ## Base
187
189
 
188
- 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 callbacks.
190
+ 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.
189
191
 
190
192
  ```rb
191
193
  plugin :rodauth do
192
194
  enable :omniauth_base
193
195
 
194
- omniauth_provider :github, ENV["GITHUB_KEY"], ENV["GITHUB_SECRET"], scope: "user"
195
- omniauth_provider :apple, ENV["CLIENT_ID"], { scope: "email name", ... }
196
+ omniauth_provider :github, ENV["GITHUB_CLIENT_ID"], ENV["GITHUB_CLIENT_SECRET"], scope: "user"
197
+ omniauth_provider :apple, ENV["APPLE_CLIENT_ID"], ENV["APPLE_CLIENT_SECRET"], scope: "email name"
196
198
  end
197
199
 
198
200
  route do |r|
@@ -355,7 +357,7 @@ Content-Type: application/json
355
357
  { "authorize_url": "https://github.com/login/oauth/authorize?..." }
356
358
  ```
357
359
 
358
- When you redirect the user to the authorize URL, and they authorize the OAuth app, the callback endpoint they're redirected to will contain query parameters that need to passed for the callback request to the backend.
360
+ When you redirect the user to the authorize URL, and they authorize the OAuth app, the callback endpoint they're redirected to will contain query parameters that need to be included in the callback request to the backend.
359
361
 
360
362
  ```http
361
363
  GET /auth/github/callback?code=...&state=...
@@ -369,13 +371,8 @@ Content-Type: application/json
369
371
  { "success": "You have been logged in" }
370
372
  ```
371
373
 
372
- If there was a login failure, the error type will be included in the response:
374
+ If there was an OmniAuth failure, the error type will be included in the response:
373
375
 
374
- ```http
375
- POST /auth/facebook/callback
376
- Accept: application/json
377
- Content-Type: application/json
378
- ```
379
376
  ```http
380
377
  500 Internal Server Error
381
378
  Content-Type: application/json
@@ -383,7 +380,7 @@ Content-Type: application/json
383
380
  { "error_type": "some_error", "error": "There was an error logging in with the external provider" }
384
381
  ```
385
382
 
386
- In this flow, you'll need to configure the callback URL on the OAuth app to point to the frontend app. On the OmniAuth strategy, you'll need to configure the same for GitHub requests, but keep the backend callback endpoint. For strategies based on [omniauth-oauth2], you can achieve this as follows:
383
+ In this flow, you'll need to configure the callback URL on the OAuth app to point to the frontend app. In the OmniAuth strategy, you'll need to configure the same redirect URL for OAuth requests, but keep the backend callback endpoint. For strategies based on [omniauth-oauth2], you can achieve this as follows:
387
384
 
388
385
  ```rb
389
386
  omniauth_provider :github, ENV["GITHUB_CLIENT_ID"], ENV["GITHUB_CLIENT_SECRET"],
@@ -203,7 +203,7 @@ module Rodauth
203
203
  end
204
204
 
205
205
  if defined?(Rodauth::Model)
206
- Rodauth::Model.register_association(:identities) do
206
+ Rodauth::Model.register_association(:omniauth) do
207
207
  { name: :identities, type: :many, table: omniauth_identities_table, key: omniauth_identities_id_column }
208
208
  end
209
209
  end
@@ -36,6 +36,8 @@ module Rodauth
36
36
  self.class.send(:define_method, :omniauth_app) { omniauth_app }
37
37
 
38
38
  self.class.roda_class.plugin :run_handler
39
+
40
+ i18n_register File.expand_path("#{__dir__}/../../../locales") if features.include?(:i18n)
39
41
  end
40
42
 
41
43
  def route!
data/locales/en.yml ADDED
@@ -0,0 +1,4 @@
1
+ en:
2
+ rodauth:
3
+ omniauth_failure_error_flash: There was an error logging in with the external provider
4
+ omniauth_login_unverified_account_error_flash: The account matching the external identity is currently awaiting verification
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "rodauth-omniauth"
3
- spec.version = "0.3.0"
3
+ spec.version = "0.3.2"
4
4
  spec.authors = ["Janko Marohnić"]
5
5
  spec.email = ["janko@hey.com"]
6
6
 
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
14
14
  spec.metadata["homepage_uri"] = spec.homepage
15
15
  spec.metadata["source_code_uri"] = spec.homepage
16
16
 
17
- spec.files = Dir["README.md", "LICENSE.txt", "*.gemspec", "lib/**/*"]
17
+ spec.files = Dir["README.md", "LICENSE.txt", "*.gemspec", "lib/**/*", "locales/**/*"]
18
18
  spec.require_paths = ["lib"]
19
19
 
20
20
  spec.add_dependency "rodauth", "~> 2.13"
@@ -28,4 +28,6 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency "net-smtp"
29
29
  spec.add_development_dependency "capybara"
30
30
  spec.add_development_dependency "jwt"
31
+ spec.add_development_dependency "rodauth-i18n"
32
+ spec.add_development_dependency "rodauth-model"
31
33
  end
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.0
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janko Marohnić
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-05 00:00:00.000000000 Z
11
+ date: 2023-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rodauth
@@ -150,6 +150,34 @@ dependencies:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rodauth-i18n
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: rodauth-model
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
153
181
  description: Rodauth extension for logging in and creating account via OmniAuth authentication.
154
182
  email:
155
183
  - janko@hey.com
@@ -161,6 +189,7 @@ files:
161
189
  - README.md
162
190
  - lib/rodauth/features/omniauth.rb
163
191
  - lib/rodauth/features/omniauth_base.rb
192
+ - locales/en.yml
164
193
  - rodauth-omniauth.gemspec
165
194
  homepage: https://github.com/janko/rodauth-omniauth
166
195
  licenses:
@@ -183,7 +212,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
183
212
  - !ruby/object:Gem::Version
184
213
  version: '0'
185
214
  requirements: []
186
- rubygems_version: 3.3.3
215
+ rubygems_version: 3.4.7
187
216
  signing_key:
188
217
  specification_version: 4
189
218
  summary: Rodauth extension for logging in and creating account via OmniAuth authentication.