Skip to content

Commit 7885540

Browse files
author
Ben Lavender
authored
Merge pull request #16 from github/v3-docs
V3 docs
2 parents 832d743 + 19db998 commit 7885540

1 file changed

Lines changed: 24 additions & 22 deletions

File tree

README.md

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# ChatopsControllers
1+
# Chatops Controller
22

33
Rails helpers for easy, JSON-RPC based chatops.
44

@@ -30,12 +30,6 @@ end
3030
Before you deploy, add the RPC authentication tokens to your app's environment,
3131
below.
3232

33-
Next, tell hubot about your endpoint:
34-
35-
```
36-
.rpc add https://myapp.githubapp.com/_chatops
37-
```
38-
3933
You're all done. Try `.echo foo`, and you should see Hubot respond with `Echoing back to you: foo`.
4034

4135
## Usage
@@ -72,7 +66,7 @@ in chat for `.help echo`.
7266
The DSL takes a block, which is the code that will run when the chat robot sees
7367
this regex. Arguments will be available in the `params` hash. `params[:user]`
7468
and `params[:room_id]` are special, and will be set by hubot. `user` will always
75-
be the github login of the user typing the command, and `room_id` will be where
69+
be the login of the user typing the command, and `room_id` will be where
7670
it was typed.
7771

7872
You can return `jsonrpc_success` with a string to return text to chat. If you
@@ -85,17 +79,26 @@ case would call `load_user` before running `echo`.
8579

8680
## Authentication
8781

88-
Add the tokens to your app's environment:
82+
Authentication uses the Chatops v3 public key signing protocol. You'll need
83+
two environment variables to use this protocol:
8984

90-
```shell
91-
$ gh-config CHATOPS_AUTH_TOKEN=abc CHATOPS_ALT_AUTH_TOKEN=abc myapp
92-
```
85+
`CHATOPS_AUTH_PUBLIC_KEY` is the public key of your chatops client in PEM
86+
format. This environment variable will contain newlines.
9387

94-
See [the protocol docs on authentication](https://github.com/github/hubot-classic/blob/master/docs/rpc_chatops_protocol.md#authentication) for more.
88+
`CHATOPS_AUTH_BASE_URL` is the base URL of your server as the chatops client
89+
sees it. This is specified as an environment variable since rails will trust
90+
client headers about forwarded host. For example, if your chatops client has
91+
added the url `https://example.com/_chatops`, you'd set this to
92+
`https://example.com`.
93+
94+
You can also set `CHATOPS_AUTH_ALT_PUBLIC_KEY` to a second public key which
95+
will be accepted. This is helpful when rolling keys.
96+
97+
TODO: link to protocol docs.
9598

9699
## Staging
97100

98-
Use `.rpc set suffix https://myapp.githubapp.com/_chatops in staging`, and all
101+
Use `.rpc set suffix https://myapp.example.com/_chatops in staging`, and all
99102
your chatops will require the suffix `in staging`. This means you can do `.echo
100103
foo` and `.echo foo in staging` to use two different servers to run `.echo foo`.
101104

@@ -110,7 +113,7 @@ script/test
110113

111114
Early versions of RPC chatops had two major changes:
112115

113-
##### They used Rails' dynamic `:action` routing, which was deprecated in Rails 5.
116+
##### Using Rails' dynamic `:action` routing, which was deprecated in Rails 5.
114117

115118
To work around this, you need to update your router boilerplate:
116119

@@ -126,9 +129,9 @@ Becomes this:
126129
post "/_chatops/:chatop", controller: "anonymous", action: :execute_chatop
127130
```
128131

129-
#####
132+
##### Adding a prefix
130133

131-
They did not require a prefix. Version 2 of the Chatops RPC protocol assumes a unique prefix for each endpoint. This decision was made for several reasons:
134+
Version 2 of the Chatops RPC protocol assumes a unique prefix for each endpoint. This decision was made for several reasons:
132135

133136
* The previous suffix-based system creates semantic ambiguities with keyword arguments
134137
* Prefixes allow big improvements to `.help`
@@ -160,9 +163,8 @@ Becomes:
160163
chat "build foobar"
161164
```
162165

163-
* Remove and re-add your endpoint with a prefix:
166+
##### Using public key authentication
164167

165-
```
166-
.rpc delete https://my-endpoint.dev
167-
.rpc add https://my-endpoint.dev with prefix ci
168-
```
168+
Previous versions used a `CHATOPS_ALT_AUTH_TOKEN` as a shared secret. This form
169+
of authentication was deprecated and the public key form used above is now
170+
used instead.

0 commit comments

Comments
 (0)