sidekiq_web_google_auth 0.2.5 → 0.3.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 +4 -4
- data/.github/workflows/release.yml +67 -0
- data/Gemfile.lock +1 -1
- data/README.md +9 -1
- data/lib/sidekiq_web_google_auth/builder.rb +1 -1
- data/lib/sidekiq_web_google_auth/extension.rb +24 -5
- data/lib/sidekiq_web_google_auth.rb +7 -2
- data/sidekiq_web_google_auth.gemspec +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1cbc79ec80b1ba37e062b43ead304a2f17652f64401f2936c09ce9e2f6a1fb30
|
|
4
|
+
data.tar.gz: 13fe54b2febb06d8089b703159fdbfde7fa2d27ce9f8d9074d3a58c2668b246b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a03839af80e1bf4356fcff87bbeb02592dc180cf6f79f3e5f0e5349ca472ce1da25211e70e1ad63ff17984d4c6cf4f93a094bbfc48932c8dcad932337d8ce295
|
|
7
|
+
data.tar.gz: 7e221cb0edf6319be3f9c08d079e1abff6ab28dae4891b1269d107542154a34351b48afd62362e5250dc874a6a8416882b01f43b4088e12119ec7f1e1c1a2241
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- master
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
release:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
permissions:
|
|
12
|
+
contents: write
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
|
|
16
|
+
- name: Extract version
|
|
17
|
+
id: version
|
|
18
|
+
run: |
|
|
19
|
+
version=$(grep -oP 'spec\.version\s*=\s*"\K[^"]+' sidekiq_web_google_auth.gemspec)
|
|
20
|
+
echo "tag=v$version" >> "$GITHUB_OUTPUT"
|
|
21
|
+
|
|
22
|
+
- name: Check if release already exists
|
|
23
|
+
id: check
|
|
24
|
+
run: |
|
|
25
|
+
if gh release view "${{ steps.version.outputs.tag }}" &>/dev/null; then
|
|
26
|
+
echo "exists=true" >> "$GITHUB_OUTPUT"
|
|
27
|
+
else
|
|
28
|
+
echo "exists=false" >> "$GITHUB_OUTPUT"
|
|
29
|
+
fi
|
|
30
|
+
env:
|
|
31
|
+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
32
|
+
|
|
33
|
+
- uses: ruby/setup-ruby@v1
|
|
34
|
+
if: steps.check.outputs.exists == 'false'
|
|
35
|
+
with:
|
|
36
|
+
ruby-version: "3.4"
|
|
37
|
+
|
|
38
|
+
- name: Build gem
|
|
39
|
+
if: steps.check.outputs.exists == 'false'
|
|
40
|
+
run: gem build sidekiq_web_google_auth.gemspec
|
|
41
|
+
|
|
42
|
+
- name: Check if version is already on RubyGems
|
|
43
|
+
id: rubygems
|
|
44
|
+
if: steps.check.outputs.exists == 'false'
|
|
45
|
+
run: |
|
|
46
|
+
version="${{ steps.version.outputs.tag }}"
|
|
47
|
+
status=$(curl -s -o /dev/null -w '%{http_code}' \
|
|
48
|
+
"https://rubygems.org/api/v2/rubygems/sidekiq_web_google_auth/versions/${version#v}.json")
|
|
49
|
+
if [ "$status" = "200" ]; then
|
|
50
|
+
echo "published=true" >> "$GITHUB_OUTPUT"
|
|
51
|
+
else
|
|
52
|
+
echo "published=false" >> "$GITHUB_OUTPUT"
|
|
53
|
+
fi
|
|
54
|
+
|
|
55
|
+
- name: Push gem to RubyGems
|
|
56
|
+
if: steps.check.outputs.exists == 'false' && steps.rubygems.outputs.published == 'false'
|
|
57
|
+
run: gem push *.gem
|
|
58
|
+
env:
|
|
59
|
+
GEM_HOST_API_KEY: ${{ secrets.GEM_HOST_API_KEY }}
|
|
60
|
+
|
|
61
|
+
- uses: softprops/action-gh-release@v3
|
|
62
|
+
if: steps.check.outputs.exists == 'false'
|
|
63
|
+
with:
|
|
64
|
+
tag_name: ${{ steps.version.outputs.tag }}
|
|
65
|
+
target_commitish: ${{ github.sha }}
|
|
66
|
+
files: "*.gem"
|
|
67
|
+
generate_release_notes: true
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -29,12 +29,20 @@ Initialize builder:
|
|
|
29
29
|
SidekiqWebGoogleAuth.setup!(
|
|
30
30
|
client_id: "example_client_id", # Google OAuth client ID
|
|
31
31
|
client_secret: "example_client_secret", # Google OAuth secret
|
|
32
|
-
# You must provide at least one of: authorized_emails,
|
|
32
|
+
# You must provide at least one of: authorized_emails, authorized_emails_domains
|
|
33
33
|
authorized_emails: %w[test@mail.com], # List of authorized emails
|
|
34
34
|
authorized_emails_domains: %w[mail.com], # List of authorized emails domains
|
|
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`.
|
|
39
|
+
|
|
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
|
+
|
|
42
|
+
## Releasing
|
|
43
|
+
|
|
44
|
+
Bump `spec.version` in the gemspec, run `bundle install` so `Gemfile.lock` records the new version, and merge both to `master`. The Release workflow then pushes the gem to RubyGems and creates a GitHub release tagged `v<version>`; a version that already has a release is skipped, and a version already on RubyGems only gets its GitHub release.
|
|
45
|
+
|
|
38
46
|
## Contributing
|
|
39
47
|
|
|
40
48
|
Bug reports and pull requests are welcome on GitHub at https://github.com/umbrellio/sidekiq_web_google_auth.
|
|
@@ -15,9 +15,7 @@ module SidekiqWebGoogleAuth
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def registered(app)
|
|
18
|
-
app
|
|
19
|
-
"Please <a href='#{root_path}auth/oauth'>authenticate via Google</a>."
|
|
20
|
-
end
|
|
18
|
+
register_sign_in_pages(app)
|
|
21
19
|
|
|
22
20
|
app.get "/auth/oauth/callback" do
|
|
23
21
|
auth = request.env["omniauth.auth"]
|
|
@@ -27,8 +25,9 @@ module SidekiqWebGoogleAuth
|
|
|
27
25
|
session[:authenticated] = true
|
|
28
26
|
redirect(root_path)
|
|
29
27
|
else
|
|
28
|
+
details = auth&.info || "missing OAuth credentials"
|
|
30
29
|
OmniAuth.logger.warn(
|
|
31
|
-
"Someone unauthorized is trying to gain access to Sidekiq: #{
|
|
30
|
+
"Someone unauthorized is trying to gain access to Sidekiq: #{details}",
|
|
32
31
|
)
|
|
33
32
|
redirect("#{root_path}auth/page")
|
|
34
33
|
end
|
|
@@ -36,7 +35,27 @@ module SidekiqWebGoogleAuth
|
|
|
36
35
|
|
|
37
36
|
app.get "/logout" do
|
|
38
37
|
session.clear
|
|
39
|
-
redirect(root_path)
|
|
38
|
+
redirect("#{root_path}auth/signed_out")
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
private
|
|
43
|
+
|
|
44
|
+
def register_sign_in_pages(app)
|
|
45
|
+
app.get "/auth/page" do
|
|
46
|
+
"Access denied. <a href='#{root_path}auth/oauth?prompt=select_account'>" \
|
|
47
|
+
"Sign in with another Google account</a>."
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
app.get "/auth/signed_out" do
|
|
51
|
+
"You have signed out. <a href='#{root_path}auth/oauth?prompt=select_account'>" \
|
|
52
|
+
"Sign in again</a>."
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
app.get "/auth/failure" do
|
|
56
|
+
message = request.params["message"].to_s
|
|
57
|
+
message = message.match?(/\A\w{1,64}\z/) ? " #{message}" : ""
|
|
58
|
+
"Google sign-in failed.#{message} <a href='#{root_path}auth/oauth'>Try again</a>."
|
|
40
59
|
end
|
|
41
60
|
end
|
|
42
61
|
end
|
|
@@ -10,10 +10,15 @@ module SidekiqWebGoogleAuth
|
|
|
10
10
|
require_relative "sidekiq_web_google_auth/builder"
|
|
11
11
|
require_relative "sidekiq_web_google_auth/extension"
|
|
12
12
|
|
|
13
|
-
def self.setup!(
|
|
13
|
+
def self.setup!(
|
|
14
|
+
client_id:, client_secret:, authorized_emails:, authorized_emails_domains:, **provider_options
|
|
15
|
+
)
|
|
16
|
+
options = { prompt: "select_account" }.merge(provider_options)
|
|
17
|
+
options[:name] = "oauth"
|
|
18
|
+
|
|
14
19
|
Sidekiq::Web.configure do |config|
|
|
15
20
|
config.use(OmniAuth::Builder) do
|
|
16
|
-
provider(:google_oauth2, client_id, client_secret,
|
|
21
|
+
provider(:google_oauth2, client_id, client_secret, **options)
|
|
17
22
|
end
|
|
18
23
|
|
|
19
24
|
SidekiqWebGoogleAuth::Extension.authorized_emails = authorized_emails
|
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.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Igor Kir
|
|
@@ -58,6 +58,7 @@ extensions: []
|
|
|
58
58
|
extra_rdoc_files: []
|
|
59
59
|
files:
|
|
60
60
|
- ".github/workflows/ci.yml"
|
|
61
|
+
- ".github/workflows/release.yml"
|
|
61
62
|
- ".gitignore"
|
|
62
63
|
- ".rspec"
|
|
63
64
|
- ".rubocop.yml"
|
|
@@ -93,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
93
94
|
- !ruby/object:Gem::Version
|
|
94
95
|
version: '0'
|
|
95
96
|
requirements: []
|
|
96
|
-
rubygems_version: 3.6.
|
|
97
|
+
rubygems_version: 3.6.9
|
|
97
98
|
specification_version: 4
|
|
98
99
|
summary: Google OAuth for Sidekiq::Web
|
|
99
100
|
test_files: []
|