omniauth-slack-openid 2.0.1 → 2.0.2

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: 4d78eeda0caabf16d7d7b0b2b575aacaa3d189f56f0456129a54b6c3d97033d7
4
- data.tar.gz: 1d5524cb8100b7f287e2480a4e5c721c0457a3916793112a0550694333143177
3
+ metadata.gz: a256da614c4c1a1a8f3dacef90e2a16274f115d0c2d54b018c29fbaf6c1e88d2
4
+ data.tar.gz: 8d4146fe35d563f9d47b32047d909ef2228ed5b24c2dbd66ff73c378592a75ae
5
5
  SHA512:
6
- metadata.gz: 9982ea29761ae211eacf1e87226d99f19a04011a71a564bb327c8acba90b99352a628f7fb7ca85bb8f6c94291404edc7a0fedf1fda781fd7a89fbd2b5416966b
7
- data.tar.gz: 9c4efdd7550b1147c261655969b9783be3c75540c448250d5293a4a37684c4d6575c9017cf9dcab5f25339f7202df37ebc32683ecd577f0a525a3c451e21918c
6
+ metadata.gz: 3249cc0e089f984a778bbc9dfaa9e7e84979eade78488681abd010d878e1d9ef49b26af5eb62b5b8316e18fbcbbbb7818eee4fb73af71e10164c2851fe4e9639
7
+ data.tar.gz: 8e463d032d37cdced78f3ad13974854a5f59ffced90f3b2e13dfd155bc8cb472bef3758b8d6d8e3ebaffb11fafafcab73c26edec9ec7003902e567e8f7ca5ed6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 2.0.2 (2026-12-02)
4
+
5
+ - Fix Sign-in with Slack when the app is mounted under a path prefix
6
+ - Keep configured workspace and scopes when a sign-in request supplies nested parameters
7
+ - Reject non-string or blank workspace and user identifiers from Slack userInfo
8
+ - Require OmniAuth 2.3.1 or newer (host checks for Sign-in with Slack callbacks)
9
+ - Require omniauth-oauth2 1.10.1 or newer and oauth2 2.1.0 or newer
10
+ - Document supported runtimes: CI-tested CRuby/MRI 3.4 and 4.0; best-effort JRuby, TruffleRuby, and other implementations that can install the runtime dependencies and run OmniAuth/Rack; Ruby older than 3.4 and Spinel AOT not supported
11
+ - Document workspace selection, scope isolation, PKCE, and token rotation for Sign-in with Slack hosts
12
+
3
13
  ## 2.0.1 (2026-07-19)
4
14
 
5
15
  - Omit `info[:email]` unless Slack reports `email_verified: true` (unverified email stays on `extra`)
data/README.md CHANGED
@@ -4,13 +4,15 @@
4
4
 
5
5
  An OmniAuth strategy for implementing Sign-in with Slack using OpenID Connect.
6
6
 
7
- Official Slack API documentation: https://api.slack.com/authentication/sign-in-with-slack
7
+ [Slack's Sign in with Slack guide](https://docs.slack.dev/authentication/sign-in-with-slack/)
8
8
 
9
9
  ## Identity model
10
10
 
11
- This strategy exchanges the OAuth authorization code for an access token, then loads identity from Slack `openid.connect.userInfo`. It does not validate Slack's `id_token` JWT (signature, `aud`, `iss`, `exp`, or `nonce`). Treat the OmniAuth AuthHash as session identity established through Slack's token and userInfo endpoints, not as a fully verified OIDC ID token.
11
+ This strategy exchanges the OAuth authorization code for an access token and loads the session identity from Slack's `openid.connect.userInfo` endpoint. Slack must supply a non-blank string for both the workspace and the user ID. The AuthHash UID has the form `team_id-user_id`.
12
12
 
13
- `info[:email]` is set only when Slack reports `email_verified: true`. Unverified addresses remain available on `extra[:data].email` and `extra[:raw_info]` when you need them for display or support flows.
13
+ The strategy leaves `id_token` opaque and provides no ID token verification. Slack's [Node](https://github.com/slackapi/node-slack-sdk/blob/main/examples/openid-connect/app.js), [Python](https://github.com/slackapi/python-slack-sdk/blob/main/integration_tests/samples/openid_connect/sanic_example.py), and [Java](https://docs.slack.dev/tools/java-slack-sdk/guides/sign-in-with-slack/) examples decode it without verifying its signature against Slack's public keys. Applications that need ID token claims for authentication must use a verifier.
14
+
15
+ `info[:email]` is set when Slack reports `email_verified: true`. Unverified addresses stay on `extra[:data].email` and `extra[:raw_info]` for display or support flows.
14
16
 
15
17
  ## Install
16
18
 
@@ -24,6 +26,12 @@ Using RubyGems:
24
26
  gem install omniauth-slack-openid
25
27
  ```
26
28
 
29
+ ## Supported runtimes
30
+
31
+ - CI-tested: CRuby/MRI 3.4 and 4.0.
32
+ - Best-effort (no CI matrix): JRuby, TruffleRuby, and other Ruby implementations that can install this gem's runtime dependencies and run OmniAuth/Rack.
33
+ - Not supported: Ruby older than 3.4. [Spinel](https://github.com/matz/spinel) AOT is not an OmniAuth host for this gem.
34
+
27
35
  ## Gemfile
28
36
 
29
37
  ```ruby
@@ -33,13 +41,9 @@ gem 'omniauth-slack-openid'
33
41
  ## Usage with Devise
34
42
 
35
43
  Create Slack app and configure OAuth & Permissions to have the following Redirect URLs:
36
- - https://localhost:3000/user/auth/slack_openid/callback
44
+ - `https://myapp.rails.fi:3000/user/auth/slack_openid/callback`
37
45
 
38
- Copy `Client ID` and `Client Secret` to your environment (e.g. `.env.local` file):
39
- ```sh
40
- SLACK_CLIENT_ID=1234567890.1234567890
41
- SLACK_CLIENT_SECRET=1234567890abcdef1234567890abcdef
42
- ```
46
+ Load `SLACK_CLIENT_ID` and `SLACK_CLIENT_SECRET` into the application environment from your credential store.
43
47
 
44
48
  Add the following to your `config/initializers/devise.rb`:
45
49
 
@@ -49,17 +53,29 @@ Add the following to your `config/initializers/devise.rb`:
49
53
  ENV.fetch("SLACK_CLIENT_ID"),
50
54
  ENV.fetch("SLACK_CLIENT_SECRET"),
51
55
  {
52
- scope: "openid,email,profile",
53
- redirect_uri: Rails.env.development? ? "https://localhost:3000/user/auth/slack_openid/callback" : nil
56
+ scope: "openid email profile",
57
+ redirect_uri: Rails.env.development? ? "https://myapp.rails.fi:3000/user/auth/slack_openid/callback" : nil
54
58
  }
55
59
  )
56
60
  ```
57
61
 
58
- Keep OmniAuth state checks enabled (`provider_ignores_state` must stay unset or false outside local debugging). Prefer fixing local TLS or `redirect_uri` over disabling CSRF state validation. For local callback testing with an HTTPS redirect registered in Slack, complete the authorize step, then if needed adjust the callback URL host scheme carefully while leaving state verification on.
62
+ Keep OmniAuth's state checks enabled and use the registered callback URL for both authorization and token exchange. Prefer a fixed `redirect_uri` (as in the example) or set `OmniAuth.config.full_host` / `OmniAuth.config.allowed_hosts` so forged Host headers cannot shape the Slack callback URL.
63
+
64
+ ### Scopes and workspaces
65
+
66
+ Request `openid` and optionally `email` and `profile`. Slack's guide uses spaces. The official SDK examples also use comma-separated scopes such as `openid,email,profile`. Request bot and other Slack API scopes in a separate OAuth flow.
67
+
68
+ Set `team: "T0123456789"` in the strategy options to suggest a workspace, including a workspace in Enterprise Grid. A `?team=T0123456789` query parameter on the sign-in POST can override the default for that request. Enforce workspace access using the workspace ID returned by Slack and your application's access policy.
69
+
70
+ ### PKCE and token rotation
71
+
72
+ Set `pkce: true` only if you have enabled PKCE for the Slack app. Enabling it in Slack marks the app as a public client. Reversing that setting requires Slack support. See [Slack's PKCE guide](https://docs.slack.dev/authentication/using-pkce/).
73
+
74
+ For expiring tokens, read `expires_at` and the supplied `refresh_token` from `auth.credentials`. If your application needs access beyond sign-in, store the credentials securely, refresh through `openid.connect.token` with `grant_type=refresh_token`, and save the replacement pair together. The host application owns token rotation. See [Slack's Sign in with Slack rotation instructions](https://docs.slack.dev/authentication/sign-in-with-slack/#token-rotation). For direct API calls, [slack-ruby-client](https://github.com/slack-ruby/slack-ruby-client) offers `openid_connect_token` and `openid_connect_userInfo`.
59
75
 
60
76
  ## Generating uid
61
77
 
62
- Gem has own `generate_uid` method that concatenates `team_id` and `user_id`, you can use it with custom parameters:
78
+ The gem provides `generate_uid`, which joins `team_id` and `user_id`. Call it with your own parameters when you need the same compound id:
63
79
 
64
80
  ```ruby
65
81
  def resolve_user_session(team_id, user_id)
@@ -72,14 +88,22 @@ end
72
88
 
73
89
  Bug reports and pull requests are welcome on GitHub at https://github.com/amkisko/omniauth-slack-openid.rb
74
90
 
91
+ Run `bundle exec ruby -Ilib usr/reports/slack_oidc_discovery.rb` to compare the live discovery endpoints and public key set with the strategy defaults.
92
+
93
+ Run `bundle exec ruby -Ilib usr/reports/runtime_support.rb` to print the engine and version and load the strategy. Maintainers may run the same command on JRuby or TruffleRuby when checking best-effort support.
94
+
95
+ For a manual sign-in smoke check, register a local `rails.fi` callback with Slack and load `SLACK_CLIENT_ID`, `SLACK_CLIENT_SECRET`, `SLACK_REDIRECT_URI`, and optionally `SLACK_TEAM` into your environment. Run `bundle exec ruby -Ilib usr/scripts/slack_oidc_smoke.rb`, open the printed URL, approve the request, then paste the full callback URL from the address bar into the hidden prompt. The CLI completes the callback locally and prints a redacted AuthHash summary. Add `--refresh` to rotate the smoke account's token and check that it returns the same Slack identity.
96
+
75
97
  ## Publishing
76
98
 
99
+ Maintainers cut a release from a clean worktree with:
100
+
77
101
  ```sh
78
- rm omniauth-slack-openid-*.gem
79
- gem build omniauth-slack-openid.gemspec
80
- gem push omniauth-slack-openid-*.gem
102
+ make release
81
103
  ```
82
104
 
105
+ That path installs appraisals, runs lint and covered polyrun specs per appraisal, checks changelog notes, builds the gem under `tmp/release`, asks for confirmation, waits for RubyGems to list the package, then tags and creates the GitHub release. Use `make release-build` for a local artifact only, or `ruby usr/bin/release.rb --artifacts DIR` to finish a partial publish.
106
+
83
107
  ## Links
84
108
 
85
109
  - [GitHub](https://github.com/amkisko/omniauth-slack-openid.rb)
@@ -2,6 +2,6 @@ require "omniauth/strategies/slack_openid"
2
2
 
3
3
  module OmniAuth
4
4
  module SlackOpenid
5
- VERSION = "2.0.1"
5
+ VERSION = "2.0.2"
6
6
  end
7
7
  end
@@ -1,10 +1,15 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "omniauth/strategies/oauth2"
2
4
 
3
5
  module OmniAuth
4
6
  module Strategies
5
7
  class SlackOpenid < OmniAuth::Strategies::OAuth2
6
8
  AUTH_OPTIONS = %i[scope team].freeze
9
+ USER_INFO_PATH = "/api/openid.connect.userInfo"
7
10
 
11
+ # keyword_init stays explicit so keyword construction matches call sites on alternate engines.
12
+ # rubocop:disable Style/RedundantStructKeywordInit
8
13
  INFO_DATA = Struct.new(
9
14
  :user_id,
10
15
  :team_id,
@@ -16,8 +21,10 @@ module OmniAuth
16
21
  :family_name,
17
22
  :locale,
18
23
  :team_name,
19
- :team_domain
24
+ :team_domain,
25
+ keyword_init: true
20
26
  )
27
+ # rubocop:enable Style/RedundantStructKeywordInit
21
28
 
22
29
  option :name, "slack_openid"
23
30
  option :client_options,
@@ -77,15 +84,16 @@ module OmniAuth
77
84
 
78
85
  def authorize_params
79
86
  super.tap do |params|
87
+ request_params = request.params
80
88
  AUTH_OPTIONS.each do |key|
81
- value = request.params[key.to_s]
82
- params[key] = value if value && !value.to_s.empty?
89
+ value = request_params[key.to_s]
90
+ params[key] = value if value.is_a?(String) && !value.empty?
83
91
  end
84
92
  end
85
93
  end
86
94
 
87
95
  def callback_url
88
- options.redirect_uri || (full_host + script_name + callback_path)
96
+ options.redirect_uri || (full_host + callback_path)
89
97
  end
90
98
 
91
99
  def raw_info
@@ -95,7 +103,7 @@ module OmniAuth
95
103
  private
96
104
 
97
105
  def fetch_and_validate_user_info
98
- response = access_token.get("/api/openid.connect.userInfo").parsed
106
+ response = access_token.get(USER_INFO_PATH).parsed
99
107
  unless response.is_a?(Hash) && response["ok"] == true
100
108
  error = response.is_a?(Hash) ? response["error"] : nil
101
109
  raise CallbackError.new(
@@ -104,9 +112,9 @@ module OmniAuth
104
112
  )
105
113
  end
106
114
 
107
- team_id = response["https://slack.com/team_id"].to_s
108
- user_id = response["https://slack.com/user_id"].to_s
109
- if team_id.empty? || user_id.empty?
115
+ team_id = response["https://slack.com/team_id"]
116
+ user_id = response["https://slack.com/user_id"]
117
+ unless valid_identifier?(team_id) && valid_identifier?(user_id)
110
118
  raise CallbackError.new(
111
119
  :invalid_credentials,
112
120
  "Slack userInfo missing team_id or user_id"
@@ -115,6 +123,10 @@ module OmniAuth
115
123
 
116
124
  response
117
125
  end
126
+
127
+ def valid_identifier?(value)
128
+ value.is_a?(String) && value.match?(/[^[:space:]]/)
129
+ end
118
130
  end
119
131
  end
120
132
  end
@@ -28,17 +28,16 @@ Gem::Specification.new do |gem|
28
28
  gem.required_ruby_version = ">= 3.4"
29
29
  gem.require_paths = ["lib"]
30
30
 
31
- gem.add_runtime_dependency "omniauth", "~> 2.0"
32
- gem.add_runtime_dependency "omniauth-oauth2", "~> 1.8"
33
- gem.add_runtime_dependency "oauth2", "~> 2.0", ">= 2.0.25"
31
+ gem.add_runtime_dependency "omniauth", "~> 2.0", ">= 2.3.1"
32
+ gem.add_runtime_dependency "omniauth-oauth2", "~> 1.8", ">= 1.10.1"
33
+ gem.add_runtime_dependency "oauth2", "~> 2.0", ">= 2.1.0"
34
34
  gem.add_runtime_dependency "base64"
35
35
 
36
36
  gem.add_development_dependency "rake", "~> 13"
37
37
  gem.add_development_dependency "rspec", "~> 3"
38
38
  gem.add_development_dependency "pry", "~> 0.15"
39
- gem.add_development_dependency "polyrun", ">= 2.2.0"
39
+ gem.add_development_dependency "polyrun", ">= 3.2.0"
40
40
  gem.add_development_dependency "bundler-audit", "~> 0.9"
41
- gem.add_development_dependency "rspec_junit_formatter", "~> 0.6"
42
41
  gem.add_development_dependency "bigdecimal"
43
42
  gem.add_development_dependency "ostruct"
44
43
  gem.add_development_dependency "tsort"
@@ -2,6 +2,7 @@ module OmniAuth
2
2
  module Strategies
3
3
  class SlackOpenid < OmniAuth::Strategies::OAuth2
4
4
  AUTH_OPTIONS: Array[Symbol]
5
+ USER_INFO_PATH: String
5
6
 
6
7
  class INFO_DATA < Struct
7
8
  attr_reader user_id: String?
@@ -42,6 +43,8 @@ module OmniAuth
42
43
  private
43
44
 
44
45
  def fetch_and_validate_user_info: () -> Hash[String, untyped]
46
+
47
+ def valid_identifier?: (untyped value) -> bool
45
48
  end
46
49
  end
47
50
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-slack-openid
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrei Makarov
@@ -16,6 +16,9 @@ dependencies:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
18
  version: '2.0'
19
+ - - ">="
20
+ - !ruby/object:Gem::Version
21
+ version: 2.3.1
19
22
  type: :runtime
20
23
  prerelease: false
21
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -23,6 +26,9 @@ dependencies:
23
26
  - - "~>"
24
27
  - !ruby/object:Gem::Version
25
28
  version: '2.0'
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: 2.3.1
26
32
  - !ruby/object:Gem::Dependency
27
33
  name: omniauth-oauth2
28
34
  requirement: !ruby/object:Gem::Requirement
@@ -30,6 +36,9 @@ dependencies:
30
36
  - - "~>"
31
37
  - !ruby/object:Gem::Version
32
38
  version: '1.8'
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: 1.10.1
33
42
  type: :runtime
34
43
  prerelease: false
35
44
  version_requirements: !ruby/object:Gem::Requirement
@@ -37,6 +46,9 @@ dependencies:
37
46
  - - "~>"
38
47
  - !ruby/object:Gem::Version
39
48
  version: '1.8'
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: 1.10.1
40
52
  - !ruby/object:Gem::Dependency
41
53
  name: oauth2
42
54
  requirement: !ruby/object:Gem::Requirement
@@ -46,7 +58,7 @@ dependencies:
46
58
  version: '2.0'
47
59
  - - ">="
48
60
  - !ruby/object:Gem::Version
49
- version: 2.0.25
61
+ version: 2.1.0
50
62
  type: :runtime
51
63
  prerelease: false
52
64
  version_requirements: !ruby/object:Gem::Requirement
@@ -56,7 +68,7 @@ dependencies:
56
68
  version: '2.0'
57
69
  - - ">="
58
70
  - !ruby/object:Gem::Version
59
- version: 2.0.25
71
+ version: 2.1.0
60
72
  - !ruby/object:Gem::Dependency
61
73
  name: base64
62
74
  requirement: !ruby/object:Gem::Requirement
@@ -119,14 +131,14 @@ dependencies:
119
131
  requirements:
120
132
  - - ">="
121
133
  - !ruby/object:Gem::Version
122
- version: 2.2.0
134
+ version: 3.2.0
123
135
  type: :development
124
136
  prerelease: false
125
137
  version_requirements: !ruby/object:Gem::Requirement
126
138
  requirements:
127
139
  - - ">="
128
140
  - !ruby/object:Gem::Version
129
- version: 2.2.0
141
+ version: 3.2.0
130
142
  - !ruby/object:Gem::Dependency
131
143
  name: bundler-audit
132
144
  requirement: !ruby/object:Gem::Requirement
@@ -141,20 +153,6 @@ dependencies:
141
153
  - - "~>"
142
154
  - !ruby/object:Gem::Version
143
155
  version: '0.9'
144
- - !ruby/object:Gem::Dependency
145
- name: rspec_junit_formatter
146
- requirement: !ruby/object:Gem::Requirement
147
- requirements:
148
- - - "~>"
149
- - !ruby/object:Gem::Version
150
- version: '0.6'
151
- type: :development
152
- prerelease: false
153
- version_requirements: !ruby/object:Gem::Requirement
154
- requirements:
155
- - - "~>"
156
- - !ruby/object:Gem::Version
157
- version: '0.6'
158
156
  - !ruby/object:Gem::Dependency
159
157
  name: bigdecimal
160
158
  requirement: !ruby/object:Gem::Requirement