Skip to content

Commit 964dea5

Browse files
committed
Updated README.
README now includes basic info on Ruby version compatibility.
1 parent f4c24b4 commit 964dea5

1 file changed

Lines changed: 53 additions & 70 deletions

File tree

README.md

Lines changed: 53 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ The omniauth-slack gem contains the Slack OAuth2 strategy for [OmniAuth](https:/
1616
the Slack [OAuth2 v2 API](https://api.slack.com/authentication/oauth-v2)
1717
and the Slack OAuth2 v1 API.
1818

19-
2019
This Gem supports Slack v2 API bot and user tokens, as well as v1 API workspace apps and tokens.
2120
Slack "classic" apps and tokens should also work but are not fully tested.
2221

22+
Omniauth-slack does not enforce a Ruby version constraint. The Gem will work with Ruby versions 2.3 through 2.6.x. Older versions of Ruby may work but are not tested. Ruby version 2.7.x may work but is not yet tested.
23+
2324

2425
## Before You Begin
2526

@@ -72,7 +73,7 @@ For a **[Sinatra](http://sinatrarb.com/)** app: <span name="sinatra-app" id=
7273
```
7374

7475

75-
If you are using **[Devise](https://github.com/plataformatec/devise)** then it will look like this:
76+
If you are using **[Devise](https://github.com/plataformatec/devise)** then it *should* look like this:
7677

7778
```ruby
7879
Devise.setup do |config|
@@ -147,7 +148,7 @@ Some of these options can also be given at runtime in the authorization request
147148
More information on provider and authentication options can be found in omniauth-slack's supporting gems [omniauth](https://github.com/omniauth/omniauth), [oauth2](https://github.com/oauth-xx/oauth2), and [omniauth-oauth2](https://github.com/omniauth/omniauth-oauth2).
148149

149150

150-
### scope *and/or* user_scope
151+
### :scope *and/or* :user_scope => space-delimited-string-of-scopes
151152
*required*
152153

153154
```ruby
@@ -160,14 +161,21 @@ More information on provider and authentication options can be found in omniauth
160161
Specify the scopes for the authorization request.
161162

162163

163-
### team
164+
### team: string
165+
*optional*
166+
167+
### team_domain: string
164168
*optional*
165169

166170
```ruby
167-
:team => 'team-id'
168-
# and/or
169-
:team_domain => 'team-subdomain'
171+
:team => 'team-id',
172+
173+
# and/or
174+
175+
:team_domain => 'my_team_domain'
170176
```
177+
Requests authentication against a specific team.
178+
171179

172180
> If you don't pass a team param, the user will be allowed to choose which team they are authenticating against. Passing this param ensures the user will auth against an account on that particular team.
173181
@@ -206,8 +214,8 @@ Sign in behavior with team settings and signed in state can be confusing. Here i
206214
* Current authorization is not requesting any non-identity scopes (but it's ok if the token already has non-identity scopes).
207215

208216

209-
### redirect_uri
210-
*optional*
217+
### redirect_uri: string
218+
String *optional*
211219

212220
```ruby
213221
:redirect_uri => 'https://<defaults-to-the-app-origin-host-and-port>/auth/slack/callback'
@@ -219,7 +227,7 @@ Set a custom redirect URI in your app, where Slack will redirect-to with an auth
219227
The redirect URI, whether default or custom, MUST match a registered redirect URI in [your app settings on api.slack.com](https://api.slack.com/apps).
220228

221229

222-
### callback_path
230+
### callback_path: string
223231
*optional*
224232

225233
```ruby
@@ -231,7 +239,7 @@ The redirect URI, whether default or custom, MUST match a registered redirect UR
231239
Set a custom callback path (path only, not the full URI) for Slack to redirect-to with an authorization code. This will be appended to the default redirect URI only. If you wish to specify a custom redirect URI with a custom callback path, just include both in the `:redirect_uri` setting.
232240

233241

234-
### skip_info
242+
### skip_info: boolean
235243
*optional*
236244

237245
```ruby
@@ -242,39 +250,8 @@ Skip building the `InfoHash` section of the `AuthHash` object.
242250

243251
If set, only a single api request will be made for each authorization. The response of that authorization request may or may not contain user and email data.
244252

245-
<!--
246-
### Preload Data with Threads
247-
*optional*
248-
249-
```ruby
250-
:preload_data_with_threads => 0
251-
```
252-
*This option is ignored if `:skip_info => true` is set.*
253-
254-
With passed integer > 0, omniauth-slack preloads the basic identity-and-info API call responses, from Slack, using *<#integer>* pooled threads.
255-
256-
The default `0` skips this feature and only loads those API calls if required, scoped, and authorized, to build the AuthHash.
257-
258-
```ruby
259-
provider :slack, key, secret, :preload_data_with_threads => 2
260-
```
261-
262-
More threads can potentially give a quicker callback phase.
263-
The caveat is an increase in concurrent request load on Slack, possibly affecting rate limits.
264-
265-
A second parameter to this option is an array of API methods to call.
266-
The possible methods are as listed above under the `:dependencies` section.
267-
The default, if the integer > 0, is to preload all of the API methods (scope dependent, of course).
268-
269-
```ruby
270-
:preload_data_with_threads => [5, %w(api_users_info api_users_profile api_users_identity)]
271-
```
272253

273-
Use this list in cooperation with the `:dependencies` option to fine-tune your `info` section, `extra` section,
274-
and post-authorization API call behavior and order.
275-
-->
276-
277-
### pass_through_params
254+
### pass_through_params: array-of-strings
278255
*optional*
279256

280257
Options for `scope`, `team`, `team_domain`, and `redirect_uri` can also be given at runtime via the query string of the omniauth-slack authorization endpoint URL `/auth/slack?team=...`. The `scope`, `team`, and `redirect_uri` query parameters will be passed directly through to Slack in the OAuth2 GET request:
@@ -299,14 +276,9 @@ To allow all pass-through options.
299276
```ruby
300277
provider :slack, KEY, SECRET, pass_through_params: %w(team scope redirect_uri team_domain)
301278
```
279+
302280

303-
304-
### history
305-
*optional*
306-
.....
307-
308-
309-
### client_options
281+
### client_options: hash-of-client-options
310282
*optional*
311283

312284
Client options control the behavior of the `OAuth2::Client`, which handles the
@@ -407,11 +379,11 @@ To extract data from the API response, call `parsed` on the response object.
407379

408380

409381
## The Auth Hash
410-
<!-- *TODO: Give a quick bit about what an auth_hash object is.* -->
411382

412-
Each Successful OmniAuth authorization places an [AuthHash](https://github.com/omniauth/omniauth/wiki/Auth-Hash-Schema) object in the environment `env['omniauth.auth']`.
413-
The AuthHash is just an enhanced hash object containing data from the [OAuth2](https://github.com/oauth-xx/oauth2) response received from
414-
the get-token API call made during the OmniAuth callback phase.
383+
Each Successful OmniAuth authorization places an
384+
[AuthHash](https://github.com/omniauth/omniauth/wiki/Auth-Hash-Schema) object in the environment `env['omniauth.auth']`.
385+
The AuthHash is just an enhanced hash object containing data from the[OAuth2](https://github.com/oauth-xx/oauth2)
386+
response received from the get-token API call made during the OmniAuth callback phase.
415387
See OmniAuth's documentation for the AuthHash schema definition.
416388

417389
With the growing number of multi-dimensional data structures for the various token response objects,
@@ -424,8 +396,8 @@ but it will no longer be mapping specific data points from the access-token
424396
to specific fields in the AuthHash `info` section (other than `info` fields that are 'required'
425397
by the OmniAuth::AuthHash schema spec).
426398

427-
Application developers are welcome to define their own `info` section
428-
directly within the omniauth-slack strategy.
399+
Application developers are welcome to define their own **`info`** section directly within the omniauth-slack strategy.
400+
And the same customization can be done for any of the top-level AuthHash sections.
429401

430402
```ruby
431403
class OmniAuth::Strategies::Slack
@@ -440,7 +412,7 @@ directly within the omniauth-slack strategy.
440412
```
441413

442414
If you want to build your own `info` section *and* have it appended to omniauth-slack's default
443-
`info` section, then subclass the strategy and use that subclass as your provider.
415+
`info` section, then subclass the strategy and use that subclass as your `OmniAuth` provider.
444416

445417
```ruby
446418
class MyCustomStrategy < OmniAuth::Strategies::Slack
@@ -453,15 +425,17 @@ If you want to build your own `info` section *and* have it appended to omniauth-
453425
end
454426
end
455427

456-
provider MyCustomStrategy, SLACK_OAUTH_KEY, SLACK_OAUTH_SECRET, scope: ...
428+
# ...
429+
430+
use OmniAuth::Builder do
431+
provider MyCustomStrategy, SLACK_OAUTH_KEY, SLACK_OAUTH_SECRET, scope: ...
432+
end
457433
```
458-
459-
The same customization can be done for any of the top-level AuthHash sections.
460434

461-
The `credentials` section of the AuthHash will contain the access-token string, the awarded
435+
The **`credentials`** section of the AuthHash will contain the access-token string, the awarded
462436
scopes, and any other essential authentication information returned in the OAuth2 response.
463437

464-
The `extra` section contains two hash keys:
438+
The **`extra`** section contains two hash keys:
465439
* `:scopes_requested` hash, which are the scopes requested during the current authorization.
466440
* `:raw_info` hash, which contains the raw response object from any API calls made during the callback phase.
467441

@@ -639,23 +613,32 @@ Don't forget to fill in your Slack API credentials. Then start up Rails, and poi
639613
When a successful authorization cycle completes, your browser should end up with a yaml representation of the auth_hash and access_token objects. What happens next is entirely up to your application.
640614

641615

642-
## Advanced
643-
644-
* Customize AuthHash with additional API calls during the callback phase.
616+
## Advanced / Experimental
645617

646-
* Deep debug with `ENV['OMNIAUTH_SLACK_DEBUG']=true`
618+
* Deep debug with `ENV['OMNIAUTH_SLACK_DEBUG']=true`.
619+
Will output a LOT of detailed TRACE log items.
620+
Only use this for debugging during development.
647621

648-
* Optional OmniAuth::Slack::VerifySlackSignature middleware handles signature
649-
verification for incoming Slack requests (experimental).
622+
* An optional `OmniAuth::Slack::VerifySlackSignature` middleware class handles signature
623+
verification for incoming Slack requests. This is helpful if you receive Slack
624+
events in your application.
650625

651626
```ruby
627+
# In your rack middleware setup file.
628+
652629
use OmniAuth::Slack::VerifySlackSignature do |config|
653630
config.app_id = ENV['SLACK_APP_ID']
654631
config.signing_secret = ENV['SLACK_SIGNING_SECRET']
655632
end
656633

657-
# When legitimate incoming Slack request comes into your app.
658-
# => env['omniauth.slack.verification'] == true
634+
# When legitimate incoming Slack request is received by your app:
635+
env['omniauth.slack.verification'] == true
636+
637+
# When illegitimate incoming Slack request is received by your app:
638+
env['omniauth.slack.verification'] == false
639+
640+
# When any other request is received by your app:
641+
env['omniauth.slack.verification'] == nil
659642

660643
```
661644

0 commit comments

Comments
 (0)