sidekiq_web_google_auth 0.3.0 → 0.3.1

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: 1cbc79ec80b1ba37e062b43ead304a2f17652f64401f2936c09ce9e2f6a1fb30
4
- data.tar.gz: 13fe54b2febb06d8089b703159fdbfde7fa2d27ce9f8d9074d3a58c2668b246b
3
+ metadata.gz: 338e2a345aedf3023bde02fa3169743497147bb30e93292823377cbcff949a06
4
+ data.tar.gz: ff7a6d37c164a171a81a8cde9a128b28d226058d6ed9fab7e6b897b7d76cb7e6
5
5
  SHA512:
6
- metadata.gz: a03839af80e1bf4356fcff87bbeb02592dc180cf6f79f3e5f0e5349ca472ce1da25211e70e1ad63ff17984d4c6cf4f93a094bbfc48932c8dcad932337d8ce295
7
- data.tar.gz: 7e221cb0edf6319be3f9c08d079e1abff6ab28dae4891b1269d107542154a34351b48afd62362e5250dc874a6a8416882b01f43b4088e12119ec7f1e1c1a2241
6
+ metadata.gz: 794d9d848099386a38363779efce2eed73a14e7c24017b3eed2c7b125cf7f5983e50563f423a739a303ade118754f87eee7f2a67d356c65225281d5bbb446828
7
+ data.tar.gz: 98105507c2e1c02e347ef17f64d782514338197b6d9b461593a17fd445df52e435aae35ebfc8711fa6467492183666658b33f4351ef5cff108e209566a866c2c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sidekiq_web_google_auth (0.3.0)
4
+ sidekiq_web_google_auth (0.3.1)
5
5
  omniauth
6
6
  omniauth-google-oauth2
7
7
  sidekiq (>= 8)
data/README.md CHANGED
@@ -35,7 +35,7 @@ SidekiqWebGoogleAuth.setup!(
35
35
  )
36
36
  ```
37
37
 
38
- Unauthenticated visitors go directly to Google. By default, Google shows the account picker (`prompt: "select_account"`). If the selected account is denied, the access-denied page links back to Google so visitors can choose another account. Logging out lands on a signed-out page instead of redirecting straight back to Google. The links on the access-denied and signed-out pages always show the account picker, even with `prompt: nil`.
38
+ Unauthenticated visitors go directly to Google. Only page loads are sent to Google; background requests from a signed-out tab, such as the dashboard's polling, get a `401` instead. By default, Google shows the account picker (`prompt: "select_account"`). If the selected account is denied, the access-denied page links back to Google so visitors can choose another account. Logging out lands on a signed-out page instead of redirecting straight back to Google. The links on the access-denied and signed-out pages always show the account picker, even with `prompt: nil`.
39
39
 
40
40
  Pass additional `omniauth-google-oauth2` options as keywords to `setup!`. For example, add `hd: "example.com", prompt: "consent select_account"` to hint at a hosted domain and request both consent and account selection. Pass `prompt: nil` to omit the configured prompt and let Google use its default sign-in behavior. The provider name is always `oauth`, even if you pass `name:`.
41
41
 
@@ -25,7 +25,21 @@ module SidekiqWebGoogleAuth
25
25
  end
26
26
 
27
27
  def deny(env)
28
- [302, { "location" => "#{env["SCRIPT_NAME"]}/auth/oauth" }, ["Found"]]
28
+ if navigation?(env)
29
+ [302, { "location" => "#{env["SCRIPT_NAME"]}/auth/oauth" }, ["Found"]]
30
+ else
31
+ [401, { "content-type" => "text/plain" }, ["Unauthorized"]]
32
+ end
33
+ end
34
+
35
+ # Background requests (e.g. dashboard polling) must not start a sign-in: it overwrites the
36
+ # OmniAuth state of a sign-in in progress.
37
+ def navigation?(env)
38
+ case env["HTTP_SEC_FETCH_MODE"]
39
+ when "navigate" then env.fetch("HTTP_SEC_FETCH_DEST", "document") == "document"
40
+ when nil then env["HTTP_ACCEPT"].to_s.include?("text/html")
41
+ else false
42
+ end
29
43
  end
30
44
 
31
45
  def session(env)
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "sidekiq_web_google_auth"
5
- spec.version = "0.3.0"
5
+ spec.version = "0.3.1"
6
6
  spec.authors = ["Igor Kir"]
7
7
  spec.email = ["igor.kir@cadolabs.io"]
8
8
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq_web_google_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Kir