Commits

Seb Ruiz committed cd99097

Port to json + jwt

Comments (0)

Files changed (5)

atlassian-connect.json

+{
+    "baseUrl": "http://localhost:3000",
+    "key": "webhook-inspector",
+    "authentication": {
+        "type": "jwt"
+    },
+    "vendor": {
+        "name": "Atlassian Labs",
+        "url": "https://developer.atlassian.com"
+    },
+    "description": "Inspect Atlassian Connect Webhooks",
+    "name": "Webhook Inspector",
+    "lifecycle": {
+        "installed": "/installed"
+    },
+    "modules": {
+        "webhooks": [
+            // Confluence
+              { "event": "attachment_created",          "url": "/attachment_created"        }
+            , { "event": "attachment_removed",          "url": "/attachment_removed"        }
+            , { "event": "attachment_updated",          "url": "/attachment_updated"        }
+            , { "event": "attachment_viewed",           "url": "/attachment_viewed"         }
+            , { "event": "blog_created",                "url": "/blog_created"              }
+            , { "event": "blog_removed",                "url": "/blog_removed"              }
+            , { "event": "blog_restored",               "url": "/blog_restored"             }
+            , { "event": "blog_trashed",                "url": "/blog_trashed"              }
+            , { "event": "blog_updated",                "url": "/blog_updated"              }
+            , { "event": "blog_viewed",                 "url": "/blog_viewed"               }
+            , { "event": "comment_created",             "url": "/comment_created"           }
+            , { "event": "comment_removed",             "url": "/comment_removed"           }
+            , { "event": "comment_updated",             "url": "/comment_updated"           }
+            , { "event": "group_created",               "url": "/group_created"             }
+            , { "event": "group_removed",               "url": "/group_removed"             }
+            , { "event": "label_added",                 "url": "/label_added"               }
+            , { "event": "label_created",               "url": "/label_created"             }
+            , { "event": "label_deleted",               "url": "/label_deleted"             }
+            , { "event": "label_removed",               "url": "/label_removed"             }
+            , { "event": "login",                       "url": "/login"                     }
+            , { "event": "login_failed",                "url": "/login_failed"              }
+            , { "event": "logout",                      "url": "/logout"                    }
+            , { "event": "page_children_reordered",     "url": "/page_children_reordered"   }
+            , { "event": "page_created",                "url": "/page_created"              }
+            , { "event": "page_moved",                  "url": "/page_moved"                }
+            , { "event": "page_removed",                "url": "/page_removed"              }
+            , { "event": "page_restored",               "url": "/page_restored"             }
+            , { "event": "page_trashed",                "url": "/page_trashed"              }
+            , { "event": "page_updated",                "url": "/page_updated"              }
+            , { "event": "page_viewed",                 "url": "/page_viewed"               }
+            , { "event": "search_performed",            "url": "/search_performed"          }
+            , { "event": "space_created",               "url": "/space_created"             }
+            , { "event": "space_logo_updated",          "url": "/space_logo_updated"        }
+            , { "event": "space_permissions_updated",   "url": "/space_permissions_updated" }
+            , { "event": "space_removed",               "url": "/space_removed"             }
+            , { "event": "space_updated",               "url": "/space_updated"             }
+            , { "event": "status_cleared",              "url": "/status_cleared"            }
+            , { "event": "status_created",              "url": "/status_created"            }
+            , { "event": "status_removed",              "url": "/status_removed"            }
+            , { "event": "user_created",                "url": "/user_created"              }
+            , { "event": "user_deactivated",            "url": "/user_deactivated"          }
+            , { "event": "user_followed",               "url": "/user_followed"             }
+            , { "event": "user_reactivated",            "url": "/user_reactivated"          }
+            , { "event": "user_removed",                "url": "/user_removed"              }
+
+            // JIRA
+            , { "event": "jira:issue_created",                         "url": "/jira-issue_created"            }
+            , { "event": "remote_issue_link_aggregate_cleared_event",  "url": "/jira-issue_created"            }
+            , { "event": "jira:worklog_updated",                       "url": "/jira-worklog_updated"          }
+            , { "event": "remote_workflow_post_function",              "url": "/remote_workflow_post_function" }
+            , { "event": "jira-webhook-post-function",                 "url": "/jira-webhook-post-function"    }
+            , { "event": "jira:issue_deleted",                         "url": "/jira-issue_deleted"            }
+            , { "event": "jira:issue_updated",                         "url": "/jira-issue_updated"            }
+        ]
+    }
+}

atlassian-plugin.xml

-<atlassian-plugin key="webhook-inspector" name="Webhook Inspect" plugins-version="2"
-  xmlns="https://remoteapps.jira.com/rest/remotable-plugins/1/installer/schema/atlassian-plugin">
-
-  <plugin-info>
-    <description>Inspect Atlassian Connect Webhooks</description>
-    <version>1</version>
-    <vendor name="Atlassian Labs" url="https://developer.atlassian.com"/>
-    <permissions>
-      <permission>create_oauth_link</permission>
-    </permissions>
-  </plugin-info>
-
-
-  <remote-plugin-container key="container" display-url="{{localBaseUrl}}">
-    <oauth>
-      <public-key>
-{{publicKey}}
-      </public-key>
-    </oauth>
-  </remote-plugin-container>
-
-  <!-- Common webhooks -->
-  <webhook key="installed" event="remote_plugin_installed" url="/installed"/>
-  <webhook key="enabled" event="remote_plugin_enabled" url="/installed"/>
-  <webhook key="remote_plugin_enabled" event="remote_plugin_enabled" url="/wh/remote_plugin_enabled"/>
-  <webhook key="remote_plugin_disabled" event="remote_plugin_disabled" url="/wh/remote_plugin_disabled"/>
-  <webhook key="server_upgraded" event="server_upgraded" url="/wh/server_upgraded"/>
-  <webhook key="plugins_upgraded" event="plugins_upgraded" url="/wh/plugins_upgraded"/>
-  <webhook key="plugin_enabled" event="plugin_enabled" url="/wh/plugin_enabled"/>
-
-  <!-- Confluence webhooks http://developer.internal.atlassian.com/static/connect/#confluence/webhook -->
-  <webhook application="confluence" key="user_reactivated" event="user_reactivated" url="/wh/user_reactivated"/>
-  <webhook application="confluence" key="attachment_viewed" event="attachment_viewed" url="/wh/attachment_viewed"/>
-  <webhook application="confluence" key="page_viewed" event="page_viewed" url="/wh/page_viewed"/>
-  <webhook application="confluence" key="logout" event="logout" url="/wh/logout"/>
-  <webhook application="confluence" key="search_performed" event="search_performed" url="/wh/search_performed"/>
-  <webhook application="confluence" key="user_deactivated" event="user_deactivated" url="/wh/user_deactivated"/>
-  <webhook application="confluence" key="page_updated" event="page_updated" url="/wh/page_updated"/>
-  <webhook application="confluence" key="attachment_removed" event="attachment_removed" url="/wh/attachment_removed"/>
-  <webhook application="confluence" key="page_moved" event="page_moved" url="/wh/page_moved"/>
-  <webhook application="confluence" key="blog_restored" event="blog_restored" url="/wh/blog_restored"/>
-  <webhook application="confluence" key="blog_trashed" event="blog_trashed" url="/wh/blog_trashed"/>
-  <webhook application="confluence" key="group_removed" event="group_removed" url="/wh/group_removed"/>
-  <webhook application="confluence" key="login_failed" event="login_failed" url="/wh/login_failed"/>
-  <webhook application="confluence" key="user_removed" event="user_removed" url="/wh/user_removed"/>
-  <webhook application="confluence" key="comment_created" event="comment_created" url="/wh/comment_created"/>
-  <webhook application="confluence" key="page_trashed" event="page_trashed" url="/wh/page_trashed"/>
-  <webhook application="confluence" key="attachment_created" event="attachment_created" url="/wh/attachment_created"/>
-  <webhook application="confluence" key="page_children_reordered" event="page_children_reordered" url="/wh/page_children_reordered"/>
-  <webhook application="confluence" key="blog_updated" event="blog_updated" url="/wh/blog_updated"/>
-  <webhook application="confluence" key="space_logo_updated" event="space_logo_updated" url="/wh/space_logo_updated"/>
-  <webhook application="confluence" key="group_created" event="group_created" url="/wh/group_created"/>
-  <webhook application="confluence" key="space_created" event="space_created" url="/wh/space_created"/>
-  <webhook application="confluence" key="space_updated" event="space_updated" url="/wh/space_updated"/>
-  <webhook application="confluence" key="label_created" event="label_created" url="/wh/label_created"/>
-  <webhook application="confluence" key="status_removed" event="status_removed" url="/wh/status_removed"/>
-  <webhook application="confluence" key="label_removed" event="label_removed" url="/wh/label_removed"/>
-  <webhook application="confluence" key="space_permissions_updated" event="space_permissions_updated" url="/wh/space_permissions_updated"/>
-  <webhook application="confluence" key="page_removed" event="page_removed" url="/wh/page_removed"/>
-  <webhook application="confluence" key="login" event="login" url="/wh/login"/>
-  <webhook application="confluence" key="user_followed" event="user_followed" url="/wh/user_followed"/>
-  <webhook application="confluence" key="space_removed" event="space_removed" url="/wh/space_removed"/>
-  <webhook application="confluence" key="blog_removed" event="blog_removed" url="/wh/blog_removed"/>
-  <webhook application="confluence" key="attachment_updated" event="attachment_updated" url="/wh/attachment_updated"/>
-  <webhook application="confluence" key="blog_viewed" event="blog_viewed" url="/wh/blog_viewed"/>
-  <webhook application="confluence" key="label_deleted" event="label_deleted" url="/wh/label_deleted"/>
-  <webhook application="confluence" key="comment_updated" event="comment_updated" url="/wh/comment_updated"/>
-  <webhook application="confluence" key="comment_removed" event="comment_removed" url="/wh/comment_removed"/>
-  <webhook application="confluence" key="page_created" event="page_created" url="/wh/page_created"/>
-  <webhook application="confluence" key="user_created" event="user_created" url="/wh/user_created"/>
-  <webhook application="confluence" key="page_restored" event="page_restored" url="/wh/page_restored"/>
-  <webhook application="confluence" key="blog_created" event="blog_created" url="/wh/blog_created"/>
-  <webhook application="confluence" key="status_created" event="status_created" url="/wh/status_created"/>
-  <webhook application="confluence" key="status_cleared" event="status_cleared" url="/wh/status_cleared"/>
-  <webhook application="confluence" key="label_added" event="label_added" url="/wh/label_added"/>
-
-  <!-- JIRA webhooks http://developer.internal.atlassian.com/static/connect/#jira/webhook -->
-
-
-</atlassian-plugin>
     // prompted the first time you start the server.
     "hosts": [
       "http://admin:admin@localhost:1990/confluence",
-    //   "http://admin:admin@localhost:2990/jira"
+      "http://admin:admin@localhost:2990/jira"
     ]
   },
 
   "dependencies": {
     "express": "~3.3.4",
     "static-expiry": ">=0.0.5",
-    "atlassian-connect-express": "~0.8.4",
+    "atlassian-connect-express": "~0.9.0-beta2",
     "colors": "*",
     "firebase": "*"
   }
 var dataRef = new Firebase('https://connect.firebaseio.com/webhook-inspector');
 
 module.exports = function (app, addon) {
-  addon.descriptor.webhooks().forEach(function (webhook) {
-    addon.on(webhook.event, function(evt, body, req){
-      var d = new Date;
-      dataRef.child(req.session.clientKey).child(evt).child(d.toISOString().replace(".","_")).set(body);
-      console.log();
-      console.log(evt.bold.yellow.inverse);
-      console.log(require('util').inspect(body,{
-        colors:true,
-        depth: 6,
-        showHidden: true,
-      }));
+
+    // Atlassian Connect Express fires events when a webhook is received, in order to authenticate the webhook for you.
+
+    addon.descriptor.modules.webhooks.forEach(function (webhook) {
+        addon.on(webhook.event, function(evt, body, req){
+            var d = new Date;
+            dataRef.child(req.session.clientKey).child(evt).child(d.toISOString().replace(".","_")).set(body);
+            console.log();
+            console.log(evt.bold.yellow.inverse);
+            console.log(require('util').inspect(body, {
+                colors: true,
+                depth: 6,
+                showHidden: true,
+            }));
+        });
     });
-  });
 };