Skip to content

Commit a3d7e48

Browse files
committed
update documentation and comments with oauth information
1 parent fdb59ea commit a3d7e48

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

documentation/secret_docs.md

+8
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,15 @@ A secrets file stores sensitive information. Unlike the repository configuration
1919
| `gh_hook_token` | specify to ensure the bot only receives GitHub notifications from pre-approved repositories | Yes | - |
2020
| `slack_access_token` | slack bot access token to enable message posting to the workspace | Yes | try to use webhooks defined in `slack_hooks` instead |
2121
| `slack_hooks` | list of channel names and their corresponding webhook endpoint | Yes | try to use token defined in `slack_access_token` instead |
22+
| `slack_client_id` | slack client ID, used for [oauth](https://api.slack.com/authentication/oauth-v2) authentication | Yes | - |
23+
| `slack_client_secret` | slack client secret, used for [oauth](https://api.slack.com/authentication/oauth-v2) authentication | Yes | - |
24+
| `slack_signing_secret` | specify to verify incoming slack requests | Yes | - |
25+
| `slack_oauth_state` | specify some unique value to maintain state b/w oauth request and callback and prevent CSRF (see [RFC6749](https://tools.ietf.org/html/rfc6749#section-4.1.1)) | Yes | - |
2226

2327
Note that either `slack_access_token` or `slack_hooks` must be defined.
2428

29+
The fields `slack_client_id`, `slack_client_secret`, `slack_signing_secret`, and `slack_oauth_state` only apply if you need to distribute the app to multiple users.
30+
2531
## `gh_token`
2632

2733
Some operations, such as fetching a config file from a private repository, or the commit corresponding to a commit comment event, require a personal access token. Refer [here](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token) for detailed instructions on token generation.
@@ -34,6 +40,8 @@ Refer [here](https://docs.github.com/en/free-pro-team@latest/developers/webhooks
3440

3541
Refer [here](https://api.slack.com/authentication/oauth-v2) for obtaining an access token via OAuth.
3642

43+
If automatic OAuth exchange is s
44+
3745
## `slack_hooks`
3846

3947
*Note: If `slack_access_token` is also defined, the bot will authenticate over Slack's Web API and this option will not be used.*

lib/action.ml

+22
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,28 @@ module Action (Github_api : Api.Github) (Slack_api : Api.Slack) = struct
233233
log#error "%s" msg;
234234
Lwt.return_unit
235235

236+
(**
237+
238+
If there is a need to distribute the app, automatic OAuth exchange must be enabled.
239+
240+
The fields `slack_client_id` and `slack_client_secret` must be configured in the
241+
secrets file. The `slack_oauth_state` field can be optionally provided to avoid
242+
forgery attacks during the OAuth exchange.
243+
(see: https://tools.ietf.org/html/rfc6749#section-4.1.1)
244+
245+
All of these fields are retrievable from the Slack app dashboard.
246+
247+
Once the server has been configured and launched, it will listen on `/slack/oauth`
248+
for incoming OAuth requests from Slack. Each user should then go to the following
249+
address, replacing the appropriate values (the `state` argument is only needed
250+
if `slack_oauth_state` is set).
251+
252+
https://slack.com/oauth/v2/authorize?scope=chat:write&client_id=<slack_client_id>&redirect_uri=<server_domain>/slack/oauth&state=<slack_oauth_state>
253+
254+
A page should open asking the user permission to install the bot to their
255+
workspace. Clicking `allow` will trigger the OAuth exchange.
256+
257+
*)
236258
let process_slack_oauth (ctx : Context.t) args =
237259
try%lwt
238260
let secrets = Context.get_secrets_exn ctx in

0 commit comments

Comments
 (0)