Browse Source

Formalise the response JSON to /configureAuthRealm for JIRA

pull/16/head
Kegan Dougal 8 years ago
parent
commit
59f7fd12a3
  1. 24
      README.md
  2. 4
      src/github.com/matrix-org/go-neb/realms/jira/jira.go
  3. 4
      src/github.com/matrix-org/go-neb/realms/jira/urls/urls.go

24
README.md

@ -154,15 +154,17 @@ Generate an RSA private key: (JIRA does not support key sizes >2048 bits)
```bash
openssl genrsa -out privkey.pem 2048
cat privkey.pem
```
Create the realm:
```
curl -X POST localhost:4050/admin/configureAuthRealm --data-binary '{
"ID": "jirarealm",
"Type": "jira",
"Config": {
"JIRAEndpoint": "matrix.org/jira/",
"ConsumerName": "goneb",
"ConsumerKey": "goneb",
"ConsumerSecret": "random_long_string",
@ -172,7 +174,27 @@ curl -X POST localhost:4050/admin/configureAuthRealm --data-binary '{
```
Returns:
```json
{
"ID": "jirarealm",
"Type": "jira",
"OldConfig": nil,
"NewConfig": {
"JIRAEndpoint": "https://matrix.org/jira/",
"Server": "Matrix.org",
"Version": "6.3.5a",
"ConsumerName": "goneb",
"ConsumerKey": "goneb",
"ConsumerSecret": "random_long_string",
"PublicKeyPEM": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA39UhbOvQHEkBP9fGnhU+\neSObTWBDGWygVYzbcONOlqEOTJUN8gmnellWqJO45S4jB1vLLnuXiHqEWnmaShIv\nbUem3QnDDqghu0gfqXHMlQr5R8ZPorTt1F2idWy1wk5rVXeLKSG7uriYhDVOVS69\nWuefoW5v55b5YZV283v2jROjxHujgAsJA7k6tvpYiSXApUl6YHmECfBoiwG9bwIt\nkHwhZ/fG9i4H8/aOyr3WlaWbVeKX+m38lmYZvzQFRd7UPU7DuO6Aiqj7RxrbAvqq\ndPeoAvo6+V0TRPZ8YzKp2yQmDcGH69IbuKJ2BG1Qx8znZAvghKQ6P9Im+M4c7j9i\ndwIDAQAB\n-----END PUBLIC KEY-----\n",
"PrivateKeyPEM": "-----BEGIN RSA PRIVATE KEY-----\r\nMIIEowIBAAKCAQEA39UhbOvQHEkBP9fGnhU+eSObTWBDGWygVYzbcONOlqEOTJUN\r\n8gmnellWqJO45S4jB1vLLnuXiHqEWnmaShIvbUem3QnDDqghu0gfqXHMlQr5R8ZP\r\norTt1F2idWy1wk5rVXeLKSG7uriYhDVOVS69WuefoW5v55b5YZV283v2jROjxHuj\r\ngAsJA7k6tvpYiSXApUl6YHmECfBoiwG9bwItkHwhZ/fG9i4H8/aOyr3WlaWbVeKX\r\n+m38lmYZvzQFRd7UPU7DuO6Aiqj7RxrbAvqqdPeoAvo6+V0TRPZ8YzKp2yQmDcGH\r\n69IbuKJ2BG1Qx8znZAvghKQ6P9Im+M4c7j9iMG72VKhDgmEwFB1acOw0lpu1XE8R1wmwG\r\nZRl/xzri3LOW2Gpc77xu6fs3NIkzQw3v1ifYhX3OrVsCIRBbDjPQI3yYjkhGx24s\r\nVhhZ5S/TkGk3Kw59bDC6KGqAuQAwX9req2l1NiuNaPU9rE7tf6Bk\r\n-----END RSA PRIVATE KEY-----"
}
}
```
The `PublicKeyPEM` must be manually inserted into the "Application Links" section under
JIRA Admin Settings by a JIRA admin on the target JIRA installation. Once that is complete,
users can OAuth on the target JIRA installation.
### Make a request for JIRA Auth

4
src/github.com/matrix-org/go-neb/realms/jira/jira.go

@ -19,6 +19,8 @@ type jiraRealm struct {
id string
privateKey *rsa.PrivateKey
JIRAEndpoint string
Server string // clobbered based on /serverInfo request
Version string // clobbered based on /serverInfo request
ConsumerName string
ConsumerKey string
ConsumerSecret string
@ -69,6 +71,8 @@ func (r *jiraRealm) Register() error {
"title": info.ServerTitle,
"version": info.Version,
}).Print("Found JIRA endpoint")
r.Server = info.ServerTitle
r.Version = info.Version
return nil
}

4
src/github.com/matrix-org/go-neb/realms/jira/urls/urls.go

@ -1,9 +1,9 @@
// Package urls handles converting between various JIRA URL representations in a consistent way. There exists three main
// types of JIRA URL which Scalar cares about:
// types of JIRA URL which Go-NEB cares about:
// - URL Keys => matrix.org/jira
// - Base URLs => https://matrix.org/jira/
// - REST URLs => https://matrix.org/jira/rest/api/2/issue/12680
// When making outbound requests to JIRA, Scalar needs to use the Base URL representation. Likewise, when Scalar
// When making outbound requests to JIRA, Go-NEB needs to use the Base URL representation. Likewise, when Go-NEB
// sends Matrix messages with JIRA URLs in them, the Base URL needs to be used to form the URL. The URL Key is
// used to determine equivalence of various JIRA installations and is mainly required when searching the database.
// The REST URLs are present on incoming webhook events and are the only way to map the event to a JIRA installation.

Loading…
Cancel
Save