Skip to content

Commit

Permalink
Item11267: Update extension topic, check api ver.
Browse files Browse the repository at this point in the history
This extension needs Foswiki 1.2  features for enforcing REST security.
Don't  register the REST handler unless API 2.3 is available.
  • Loading branch information
gac410 committed Aug 21, 2014
1 parent b04ffc3 commit 1547170
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 12 deletions.
15 changes: 10 additions & 5 deletions data/System/FoswikiOrgPlugin.txt
@@ -1,31 +1,36 @@
%META:TOPICINFO{author="ProjectContributor" date="1401067543" format="1.1" version="1"}% %META:TOPICINFO{author="ProjectContributor" date="1408579046" format="1.1" version="1"}%
%META:TOPICPARENT{name="Plugins"}% %META:TOPICPARENT{name="Plugins"}%
<!-- <!--
One line description, required for extensions repository catalog. One line description, required for extensions repository catalog.
* Set SHORTDESCRIPTION = %$SHORTDESCRIPTION% * Set SHORTDESCRIPTION = %$SHORTDESCRIPTION%
--> -->
---+!! Empty Plugin ---+!! !FoswikiOrg Plugin


%SHORTDESCRIPTION% %SHORTDESCRIPTION%


%TOC% %TOC%


Implements Foswiki.org specific hooks and processing. Implements Foswiki.org specific hooks and processing.


* REST handler to update tasks from notification of push events. Requires a secret key shared with http://github.com/
* beforeSaveHandler eventually implements automatic security controls on Tasks.

---++ Preferences ---++ Preferences


Configuration is done witin =bin/configure=. See configure for documentation.

---++ Installation ---++ Installation
%$INSTALL_INSTRUCTIONS% %$INSTALL_INSTRUCTIONS%


---++ Info ---++ Info


| Author: | ProjectContributor | | Author: | GeorgeClark |
| Copyright: | %$CREATEDYEAR%, ProjectContributor, All Rights Reserved | | Copyright: | 2014, ProjectContributor, All Rights Reserved |
| License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) | | License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) |
| Dependencies: | %$DEPENDENCIES% | | Dependencies: | %$DEPENDENCIES% |
| Version: | %$VERSION% | | Version: | %$VERSION% |
| Release: | %$RELEASE% | | Release: | %$RELEASE% |
| Change&nbsp;History: | <!-- versions below in reverse order -->&nbsp; | | Change&nbsp;History: | <!-- versions below in reverse order -->&nbsp; |
| 1.0 (%$CREATEDATE%): | Initial version | | 1.0 (2014-08-20): | Initial version |
| Home: | http://foswiki.org/Extensions/%TOPIC% | | Home: | http://foswiki.org/Extensions/%TOPIC% |
| Support: | http://foswiki.org/Support/%TOPIC% | | Support: | http://foswiki.org/Support/%TOPIC% |
28 changes: 21 additions & 7 deletions lib/Foswiki/Plugins/FoswikiOrgPlugin.pm
Expand Up @@ -16,14 +16,28 @@ our $NO_PREFS_IN_TOPIC = 1;


# Plugin init method, used to initialise handlers # Plugin init method, used to initialise handlers
sub initPlugin { sub initPlugin {
Foswiki::Func::registerRESTHandler(
'githubpush', \&_RESTgithubpush, # check for Plugins.pm versions, don't register REST handler
validate => 0, # No strikeone applicable # on older versions of Foswiki.
authenticate => 0, # Github push provides a security token for checking if ( $Foswiki::Plugins::VERSION < 2.3 ) {
http_allow => 'GET,POST', # Github only will POST. Foswiki::Func::writeWarning(
description => 'Version mismatch between ',
__PACKAGE__,
' and Plugins.pm, skipping REST Handler'
);
}
else {
Foswiki::Func::registerRESTHandler(
'githubpush', \&_RESTgithubpush,
validate => 0, # No strikeone applicable
authenticate =>
0, # Github push provides a security token for checking
http_allow => 'POST', # Github only will POST.
description =>
'Handle webhook push requests from GitHub. Secured by HMAC hash of payload with shared secret.' 'Handle webhook push requests from GitHub. Secured by HMAC hash of payload with shared secret.'
); );
}

return 1; return 1;
} }


Expand Down

0 comments on commit 1547170

Please sign in to comment.