├── .gitignore
├── test.php
├── assets
└── aperture-account-activated.png
├── .codeclimate.yml
├── .github
└── CONTRIBUTING.md
├── .svnignore
├── .phpcs.xml
├── LICENSE.txt
├── README.md
├── .travis.yml
├── readme.txt
├── deploy.sh
└── aperture.php
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 |
--------------------------------------------------------------------------------
/test.php:
--------------------------------------------------------------------------------
1 |
2 |
3 | WordPress Indieauth Standards
4 |
5 | ./aperture.php
6 | */vendor/*
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Aaron Parecki
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # WordPress Aperture Plugin
2 |
3 | This plugin adds a [Microsub](https://indieweb.org/Microsub) endpoint to your WordPress site by using the hosted [Aperture](https://aperture.p3k.io) service. This lets you log in to social readers like [Monocle](https://monocle.p3k.io) and [Indigenous](https://indigenous.abode.pub/ios/).
4 |
5 | Available in the WordPress plugin directory at [wordpress.org/plugins/aperture](https://wordpress.org/plugins/aperture/).
6 |
7 | > This plugin requires the [WordPress IndieAuth plugin](https://wordpress.org/plugins/indieauth/). Please ensure that plugin is installed and activated first before attempting to install the Aperture plugin.
8 |
9 | When this plugin is activated, it registers a new account at [Aperture](https://aperture.p3k.io). The `` tag is then added to your WordPress site automatically.
10 |
11 | 
12 |
13 | After activating this plugin, you should be able to log in to Aperture and Microsub clients. Note that no data is stored in WordPress, this plugin just sets the appropriate tags so that you can use Aperture as your Microsub server.
14 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: false
2 | dist: trusty
3 | language: php
4 | php:
5 | - 5.6
6 | cache:
7 | directories:
8 | - vendor
9 | - $HOME/.composer/cache
10 | after_success: curl -L https://raw.githubusercontent.com/aaronpk/aperture-wordpress/master/deploy.sh | bash
11 | matrix:
12 | include:
13 | - php: 5.6
14 | env: WP_VERSION=latest WP_MULTISITE=0 WP_PULUGIN_DEPLOY=1
15 | env:
16 | global:
17 | - SVN_REPO: https://plugins.svn.wordpress.org/aperture/
18 | - GH_REF: https://github.com/aaronpk/aperture-wordpress.git
19 | - secure: "qzCqyzStR+E5Me4/PU5yttxYahrvfeE7Bn3NCkmVMrKxSIsq4G1GDb2MYdh5mkwYoL3JsTCHCJl6ffxnKlue0ATVJIZKurz41cwaKDrsWmGb6ucBl9f2pO2Kx7a+ktPt22dRpZAAfaUm32EiOjvEVYyuAl7WAEX5F+bXK8zGRPTRnRLVaDk6QpSzEcsZ+vQ1KuVDAJPkBOnzYV9q4sZnGsbz1QZ0SiThfObbcIxfq+rkRD2GjWaZo7rUsKYfLmhvjPMs1uzTWaVfAEX6Sy2XbACD4kiXd5SJ9QpwI5Vf3LFOV8/a23PyCc8kJSzQstopQOOzf3H3E29oEqk6BLF0lL9f8Ke7NncBxBv14V/VjsgjkLW7Vp1RcxInIU0d+E4/j9btU7qjDtK/SCJdmd8ZQjHcyiA4VmTym5Em2fq9DAD8e+0wlVHuaBXN4vGbHbj/nTB4a0+0Y4pMlbaRQHDSWtx9emZsOBvtoNBUCGOFtT1+fiH9vLFsa8kGgBjQN+WhF7uvkaRQYF4i7GkIXzl6r2sAS4MBkkZ4uMAeRhDSrfVfOzgRjBeuqlRtvsRCvF12AHHn5kpoiPnk6ycTs0zAWGQ+0RjKArTzjUYUovsMfuV/53kJj7Kbw2Ko96Gi3agImvb6F9Ems2h4pw43WXhJ+/QRSxMFiZ/oPtvWhTKowe8="
20 | script: php test.php
21 |
--------------------------------------------------------------------------------
/readme.txt:
--------------------------------------------------------------------------------
1 | === Aperture ===
2 | Contributors: aaronpk
3 | Tags: indieweb, microsub, aperture
4 | Requires at least: 4.7
5 | Requires PHP: 5.3
6 | Tested up to: 4.9.8
7 | Stable tag: trunk
8 | License: MIT
9 | License URI: https://opensource.org/licenses/MIT
10 | Donate link: https://opencollective.com/indieweb
11 |
12 | This plugin adds a Microsub endpoint to your WordPress site by using the hosted Aperture service. This lets you log in to social readers like Monocle and Indigenous.
13 |
14 | == Description ==
15 |
16 | This plugin adds a [Microsub](https://indieweb.org/Microsub) endpoint to your WordPress site by using the hosted [Aperture](https://aperture.p3k.io) service. This lets you log in to social readers like [Monocle](https://monocle.p3k.io) and [Indigenous](https://indigenous.abode.pub/ios/).
17 |
18 | This plugin requires the [WordPress IndieAuth plugin](https://wordpress.org/plugins/indieauth/). Please ensure that plugin is installed and activated first before attempting to install the Aperture plugin.
19 |
20 | When this plugin is activated, it registers a new account at [Aperture](https://aperture.p3k.io). The `` tag is then added to your WordPress site automatically.
21 |
22 | == Screenshots ==
23 |
24 | 1. aperture-account-activated.png
25 |
26 | == Frequently Asked Questions ==
27 |
28 | None yet.
29 |
30 | == Upgrade Notice ==
31 |
32 | None yet.
33 |
34 | == Changelog ==
35 |
36 | = 1.0.0 (2018-08-11) =
37 |
38 | * Initial release
39 |
--------------------------------------------------------------------------------
/deploy.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # from https://raw.githubusercontent.com/miya0001/travis2wpplugin/master/deploy.sh
3 |
4 | set -e
5 |
6 | if [[ "false" != "$TRAVIS_PULL_REQUEST" ]]; then
7 | echo "Not deploying pull requests."
8 | exit
9 | fi
10 |
11 | if [[ ! $WP_PULUGIN_DEPLOY ]]; then
12 | echo "Not deploying."
13 | exit
14 | fi
15 |
16 | if [[ ! $SVN_REPO ]]; then
17 | echo "SVN repo is not specified."
18 | exit
19 | fi
20 |
21 | # Untrailing slash of SVN_REPO path
22 | SVN_REPO=`echo $SVN_REPO | sed -e "s/\/$//"`
23 | # Git repository
24 | GH_REF=https://github.com/${TRAVIS_REPO_SLUG}.git
25 |
26 | echo "Starting deploy..."
27 |
28 | mkdir build
29 |
30 | cd build
31 | BASE_DIR=$(pwd)
32 |
33 | echo "Checking out trunk from $SVN_REPO ..."
34 | svn co -q $SVN_REPO/trunk
35 |
36 | echo "Getting clone from $GH_REF to $SVN_REPO ..."
37 | git clone -q $GH_REF ./git
38 |
39 | cd ./git
40 |
41 | if [ -e "bin/build.sh" ]; then
42 | echo "Starting bin/build.sh."
43 | bash bin/build.sh
44 | fi
45 |
46 | cd $BASE_DIR
47 |
48 | echo "Syncing git repository to svn"
49 | rsync -a --exclude=".svn" --checksum --delete ./git/ ./trunk/
50 | rm -fr ./git
51 |
52 | cd ./trunk
53 |
54 | if [ -e ".distignore" ]; then
55 | echo "svn propset form .distignore"
56 | svn propset -q -R svn:ignore -F .distignore .
57 |
58 | else
59 | if [ -e ".svnignore" ]; then
60 | echo "svn propset"
61 | svn propset -q -R svn:ignore -F .svnignore .
62 | fi
63 | fi
64 |
65 | echo "Run svn add"
66 | svn st | grep '^!' | sed -e 's/\![ ]*/svn del -q /g' | sh
67 | echo "Run svn del"
68 | svn st | grep '^?' | sed -e 's/\?[ ]*/svn add -q /g' | sh
69 |
70 | # If tag number and credentials are provided, commit to trunk.
71 | if [[ $TRAVIS_TAG && $SVN_USER && $SVN_PASS ]]; then
72 | if [[ ! -d tags/$TRAVIS_TAG ]]; then
73 | echo "Commit to $SVN_REPO."
74 | svn commit -m "commit version $TRAVIS_TAG" --username $SVN_USER --password $SVN_PASS --non-interactive 2>/dev/null
75 | echo "Take snapshot of $TRAVIS_TAG"
76 | svn copy $SVN_REPO/trunk $SVN_REPO/tags/$TRAVIS_TAG -m "Take snapshot of $TRAVIS_TAG" --username $SVN_USER --password $SVN_PASS --non-interactive 2>/dev/null
77 | else
78 | echo "tags/$TRAVIS_TAG already exists."
79 | fi
80 | else
81 | echo "Nothing to commit and check \`svn st\`."
82 | svn st
83 | fi
84 |
--------------------------------------------------------------------------------
/aperture.php:
--------------------------------------------------------------------------------
1 | WP_REST_Server::CREATABLE,
37 | 'callback' => array( $this, 'verification' ),
38 | 'args' => array(),
39 | ),
40 | )
41 | );
42 | }
43 |
44 | public function activated() {
45 |
46 | // Check for the IndieAuth plugin and show an error if it's not installed
47 | if( !class_exists( 'IndieAuth_Admin' ) ) {
48 | deactivate_plugins( plugin_basename( __FILE__ ) );
49 | wp_die( 'This plugin requires the WordPress IndieAuth plugin. Please go back and install that plugin first.' );
50 | }
51 |
52 | // Register a new account on Aperture and store the resulting Microsub endpoint
53 |
54 | // Generate a temporary code so that Aperture can verify this request
55 | $code = wp_generate_password( 128, false );
56 |
57 | // Store the code in the options table
58 | update_option( 'aperture_temporary_code', $code );
59 |
60 | $verification_endpoint = rest_url( '/aperture/1.0/verification' );
61 |
62 | $version = get_plugin_data( __FILE__)['Version'];
63 |
64 | $args = array(
65 | 'headers' => array(
66 | 'Accept' => 'application/json',
67 | 'Content-Type' => 'application/x-www-form-urlencoded',
68 | ),
69 | 'body' => array(
70 | 'verification_endpoint' => $verification_endpoint,
71 | 'code' => $code,
72 | 'site' => home_url( '/' ), // this needs to be the same URL that the IndieAuth plugin returns as the identity
73 | 'via' => 'aperture-wordpress/' . $version,
74 | ),
75 | );
76 | $endpoint = APERTURE_SERVER.'/api/register';
77 |
78 | $response = wp_remote_post( $endpoint, $args );
79 | }
80 |
81 | public function verification() {
82 | // Aperture always sends the code we generated, make sure it's in the database
83 | if( isset($_POST['code']) ) {
84 |
85 | if( get_option( 'aperture_temporary_code' ) != $_POST['code']) {
86 | return new WP_REST_Response( array( 'error' => 'invalid code' ), 400 );
87 | }
88 |
89 | if( isset( $_POST['challenge'] ) ) {
90 | // WP_REST_Response seems to always encode the parameter as JSON, meaning this ends up returning "foo" with quotes
91 | #return new WP_REST_Response( $_POST['challenge'], 200, array( 'Content-Type' => 'text/plain' ) );
92 | header('Content-Type: text/plain');
93 | echo $_POST['challenge'];
94 | die();
95 | }
96 |
97 | if( isset( $_POST['error'] ) ) {
98 | // Aperture reports validation errors here
99 | update_option( 'aperture_registration_error', $_POST['error'] );
100 | return new WP_REST_Response( 'ok' );
101 | }
102 |
103 | if( isset( $_POST['microsub'] ) ) {
104 | update_option( 'aperture_microsub_url', $_POST['microsub'] );
105 | update_option( 'aperture_registration_success', 'Successfully registered a new account! You can now log in to Aperture and Microsub readers!' );
106 | return new WP_REST_Response( 'ok' );
107 | }
108 |
109 | }
110 | }
111 |
112 | public function display_error() {
113 | $message = get_option( 'aperture_registration_error' );
114 | ?>
115 |
118 |
125 |
128 |
135 |
136 |