{"action":"created","comment":{"url":"https://api.github.com/repos/snarfed/wordpress-micropub/pulls/comments/201818701","pull_request_review_id":136387318,"id":201818701,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMTgxODcwMQ==","diff_hunk":"@@ -0,0 +1,218 @@\n+<?php\n+\n+/* For debugging purposes this will bypass Micropub authentication\n+ * in favor of WordPress authentication\n+ * Using this to test querying(q=) parameters quickly\n+ */\n+// Allows for a custom Authentication and Token Endpoint\n+if ( ! defined( 'MICROPUB_AUTHENTICATION_ENDPOINT' ) ) {\n+\tdefine( 'MICROPUB_AUTHENTICATION_ENDPOINT', 'https://indieauth.com/auth' );\n+}\n+if ( ! defined( 'MICROPUB_TOKEN_ENDPOINT' ) ) {\n+\tdefine( 'MICROPUB_TOKEN_ENDPOINT', 'https://tokens.indieauth.com/token' );\n+}\n+\n+add_action( 'plugins_loaded', array( 'Micropub_Authorize', 'init' ) );\n+\n+/**\n+ * Micropub IndieAuth Authorization Class\n+ */\n+class Micropub_Authorize {\n+\n+\t// associative array, populated by authorize().\n+\tprotected static $micropub_auth_response;\n+\n+\t// Array of Scopes\n+\tprotected static $scopes;\n+\n+\t/**\n+\t * Initialize the plugin.\n+\t */\n+\tpublic static function init() {\n+\t\t$cls = get_called_class();\n+\n+\t\tadd_action( 'wp_head', array( $cls, 'html_header' ), 99 );\n+\t\tadd_action( 'send_headers', array( $cls, 'http_header' ) );\n+\t\tadd_filter( 'host_meta', array( $cls, 'jrd_links' ) );\n+\t\tadd_filter( 'webfinger_user_data', array( $cls, 'jrd_links' ) );\n+\t\t// The WordPress IndieAuth plugin uses priority 30\n+\t\tadd_filter( 'determine_current_user', array( $cls, 'determine_current_user' ), 31 );\n+\t}\n+\n+\tpublic static function indieauth_scopes( $scopes ) {\n+\t\treturn static::$scopes;\n+\t}\n+\tpublic static function indieauth_response( $response ) {\n+\t\treturn static::$micropub_auth_response;\n+\t}\n+\n+\tpublic static function header( $header, $value ) {\n+\t\t\theader( $header . ': ' . $value, false );\n+\t}\n+\n+\tpublic static function http_header() {\n+\t\t\tstatic::header( 'Link', '<' . get_option( 'indieauth_authorization_endpoint', MICROPUB_AUTHENTICATION_ENDPOINT ) . '>; rel=\"authorization_endpoint\"' );\n+\t\t\tstatic::header( 'Link', '<' . get_option( 'indieauth_token_endpoint', MICROPUB_TOKEN_ENDPOINT ) . '>; rel=\"token_endpoint\"' );\n+\t}\n+\tpublic static function html_header() {\n+\t\t\tprintf( '<link rel=\"authorization_endpoint\" href=\"%s\" />' . PHP_EOL, get_option( 'indieauth_authorization_endpoint', MICROPUB_AUTHENTICATION_ENDPOINT ) );\n+\t\t\tprintf( '<link rel=\"token_endpoint\" href=\"%s\" />' . PHP_EOL, get_option( 'indieauth_token_endpoint', MICROPUB_TOKEN_ENDPOINT ) );\n+\t}\n+\n+\tpublic static function jrd_links( $array ) {\n+\t\t$array['links'][] = array(\n+\t\t\t'rel'  => 'authorization_endpoint',\n+\t\t\t'href' => get_option( 'indieauth_authorization_endpoint', MICROPUB_AUTHENTICATION_ENDPOINT ),\n+\t\t);\n+\t\t$array['links'][] = array(\n+\t\t\t'rel'  => 'token_endpoint',\n+\t\t\t'href' => get_option( 'indieauth_token_endpoint', MICROPUB_TOKEN_ENDPOINT ),\n+\t\t);\n+\n+\t\treturn $array;\n+\t}\n+\n+\tpublic static function get( $array, $key, $default = array() ) {\n+\t\tif ( is_array( $array ) ) {\n+\t\t\treturn isset( $array[ $key ] ) ? $array[ $key ] : $default;\n+\t\t}\n+\t\treturn $default;\n+\t}\n+\n+\t/**\n+\t * Get the authorization header","path":"includes/class-micropub-authorize.php","position":83,"original_position":83,"commit_id":"7d784c33f3e710ff81efaa35b6379132fba4612f","original_commit_id":"7d784c33f3e710ff81efaa35b6379132fba4612f","user":{"login":"snarfed","id":778068,"node_id":"MDQ6VXNlcjc3ODA2OA==","avatar_url":"https://avatars2.githubusercontent.com/u/778068?v=4","gravatar_id":"","url":"https://api.github.com/users/snarfed","html_url":"https://github.com/snarfed","followers_url":"https://api.github.com/users/snarfed/followers","following_url":"https://api.github.com/users/snarfed/following{/other_user}","gists_url":"https://api.github.com/users/snarfed/gists{/gist_id}","starred_url":"https://api.github.com/users/snarfed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snarfed/subscriptions","organizations_url":"https://api.github.com/users/snarfed/orgs","repos_url":"https://api.github.com/users/snarfed/repos","events_url":"https://api.github.com/users/snarfed/events{/privacy}","received_events_url":"https://api.github.com/users/snarfed/received_events","type":"User","site_admin":false},"body":"this is so great! thank you for adding it! it's probably been the single biggest pain point for users for a while now. did you get the code from @zegnat?\r\n\r\nit's probably worth a unit test. mind adding one? and also updating the docs, specifically the _Frequently Asked Questions_ section in the readme?","created_at":"2018-07-11T19:50:37Z","updated_at":"2018-07-11T20:04:04Z","html_url":"https://github.com/snarfed/wordpress-micropub/pull/135#discussion_r201818701","pull_request_url":"https://api.github.com/repos/snarfed/wordpress-micropub/pulls/135","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/snarfed/wordpress-micropub/pulls/comments/201818701"},"html":{"href":"https://github.com/snarfed/wordpress-micropub/pull/135#discussion_r201818701"},"pull_request":{"href":"https://api.github.com/repos/snarfed/wordpress-micropub/pulls/135"}}},"pull_request":{"url":"https://api.github.com/repos/snarfed/wordpress-micropub/pulls/135","id":200576440,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAwNTc2NDQw","html_url":"https://github.com/snarfed/wordpress-micropub/pull/135","diff_url":"https://github.com/snarfed/wordpress-micropub/pull/135.diff","patch_url":"https://github.com/snarfed/wordpress-micropub/pull/135.patch","issue_url":"https://api.github.com/repos/snarfed/wordpress-micropub/issues/135","number":135,"state":"open","locked":false,"title":"Split off Authorization","user":{"login":"dshanske","id":7278204,"node_id":"MDQ6VXNlcjcyNzgyMDQ=","avatar_url":"https://avatars0.githubusercontent.com/u/7278204?v=4","gravatar_id":"","url":"https://api.github.com/users/dshanske","html_url":"https://github.com/dshanske","followers_url":"https://api.github.com/users/dshanske/followers","following_url":"https://api.github.com/users/dshanske/following{/other_user}","gists_url":"https://api.github.com/users/dshanske/gists{/gist_id}","starred_url":"https://api.github.com/users/dshanske/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dshanske/subscriptions","organizations_url":"https://api.github.com/users/dshanske/orgs","repos_url":"https://api.github.com/users/dshanske/repos","events_url":"https://api.github.com/users/dshanske/events{/privacy}","received_events_url":"https://api.github.com/users/dshanske/received_events","type":"User","site_admin":false},"body":"This PR splits authorization into its own file. It also changes the load process for it by making it use the WordPress login functionality of get_current_user_id, which calls wp_get_current_user which calls the determine_current_user filter\r\n\r\nAs one change, if it cannot determine a user ID, it will not let the post  be made, as it cannot match it up with an existing user. I think this can be addressed by improving user_url, which I intend to update in a future PR to include the improvements made in the similar IndieAuth function...matching the default user if set by the  IndieWeb plugin, checking to see if there is only a single user, or only a single user with author permissions, etc. Also, allowing the author URL(/author/snarfed) as an initial URL.) \r\n\r\nAs part of  the changes I'm trying to make, I'm  trying to move the  code to work more within the WordPress core code, and trying to divide this work into pieces. ","created_at":"2018-07-11T03:18:53Z","updated_at":"2018-07-11T20:04:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f4d3946565927b311f769fffc1d5cc584d29df97","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/snarfed/wordpress-micropub/pulls/135/commits","review_comments_url":"https://api.github.com/repos/snarfed/wordpress-micropub/pulls/135/comments","review_comment_url":"https://api.github.com/repos/snarfed/wordpress-micropub/pulls/comments{/number}","comments_url":"https://api.github.com/repos/snarfed/wordpress-micropub/issues/135/comments","statuses_url":"https://api.github.com/repos/snarfed/wordpress-micropub/statuses/7d784c33f3e710ff81efaa35b6379132fba4612f","head":{"label":"dshanske:authorize","ref":"authorize","sha":"7d784c33f3e710ff81efaa35b6379132fba4612f","user":{"login":"dshanske","id":7278204,"node_id":"MDQ6VXNlcjcyNzgyMDQ=","avatar_url":"https://avatars0.githubusercontent.com/u/7278204?v=4","gravatar_id":"","url":"https://api.github.com/users/dshanske","html_url":"https://github.com/dshanske","followers_url":"https://api.github.com/users/dshanske/followers","following_url":"https://api.github.com/users/dshanske/following{/other_user}","gists_url":"https://api.github.com/users/dshanske/gists{/gist_id}","starred_url":"https://api.github.com/users/dshanske/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dshanske/subscriptions","organizations_url":"https://api.github.com/users/dshanske/orgs","repos_url":"https://api.github.com/users/dshanske/repos","events_url":"https://api.github.com/users/dshanske/events{/privacy}","received_events_url":"https://api.github.com/users/dshanske/received_events","type":"User","site_admin":false},"repo":{"id":30734997,"node_id":"MDEwOlJlcG9zaXRvcnkzMDczNDk5Nw==","name":"wordpress-micropub","full_name":"dshanske/wordpress-micropub","owner":{"login":"dshanske","id":7278204,"node_id":"MDQ6VXNlcjcyNzgyMDQ=","avatar_url":"https://avatars0.githubusercontent.com/u/7278204?v=4","gravatar_id":"","url":"https://api.github.com/users/dshanske","html_url":"https://github.com/dshanske","followers_url":"https://api.github.com/users/dshanske/followers","following_url":"https://api.github.com/users/dshanske/following{/other_user}","gists_url":"https://api.github.com/users/dshanske/gists{/gist_id}","starred_url":"https://api.github.com/users/dshanske/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dshanske/subscriptions","organizations_url":"https://api.github.com/users/dshanske/orgs","repos_url":"https://api.github.com/users/dshanske/repos","events_url":"https://api.github.com/users/dshanske/events{/privacy}","received_events_url":"https://api.github.com/users/dshanske/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dshanske/wordpress-micropub","description":"A Micropub server plugin for WordPress","fork":true,"url":"https://api.github.com/repos/dshanske/wordpress-micropub","forks_url":"https://api.github.com/repos/dshanske/wordpress-micropub/forks","keys_url":"https://api.github.com/repos/dshanske/wordpress-micropub/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dshanske/wordpress-micropub/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dshanske/wordpress-micropub/teams","hooks_url":"https://api.github.com/repos/dshanske/wordpress-micropub/hooks","issue_events_url":"https://api.github.com/repos/dshanske/wordpress-micropub/issues/events{/number}","events_url":"https://api.github.com/repos/dshanske/wordpress-micropub/events","assignees_url":"https://api.github.com/repos/dshanske/wordpress-micropub/assignees{/user}","branches_url":"https://api.github.com/repos/dshanske/wordpress-micropub/branches{/branch}","tags_url":"https://api.github.com/repos/dshanske/wordpress-micropub/tags","blobs_url":"https://api.github.com/repos/dshanske/wordpress-micropub/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dshanske/wordpress-micropub/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dshanske/wordpress-micropub/git/refs{/sha}","trees_url":"https://api.github.com/repos/dshanske/wordpress-micropub/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dshanske/wordpress-micropub/statuses/{sha}","languages_url":"https://api.github.com/repos/dshanske/wordpress-micropub/languages","stargazers_url":"https://api.github.com/repos/dshanske/wordpress-micropub/stargazers","contributors_url":"https://api.github.com/repos/dshanske/wordpress-micropub/contributors","subscribers_url":"https://api.github.com/repos/dshanske/wordpress-micropub/subscribers","subscription_url":"https://api.github.com/repos/dshanske/wordpress-micropub/subscription","commits_url":"https://api.github.com/repos/dshanske/wordpress-micropub/commits{/sha}","git_commits_url":"https://api.github.com/repos/dshanske/wordpress-micropub/git/commits{/sha}","comments_url":"https://api.github.com/repos/dshanske/wordpress-micropub/comments{/number}","issue_comment_url":"https://api.github.com/repos/dshanske/wordpress-micropub/issues/comments{/number}","contents_url":"https://api.github.com/repos/dshanske/wordpress-micropub/contents/{+path}","compare_url":"https://api.github.com/repos/dshanske/wordpress-micropub/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dshanske/wordpress-micropub/merges","archive_url":"https://api.github.com/repos/dshanske/wordpress-micropub/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dshanske/wordpress-micropub/downloads","issues_url":"https://api.github.com/repos/dshanske/wordpress-micropub/issues{/number}","pulls_url":"https://api.github.com/repos/dshanske/wordpress-micropub/pulls{/number}","milestones_url":"https://api.github.com/repos/dshanske/wordpress-micropub/milestones{/number}","notifications_url":"https://api.github.com/repos/dshanske/wordpress-micropub/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dshanske/wordpress-micropub/labels{/name}","releases_url":"https://api.github.com/repos/dshanske/wordpress-micropub/releases{/id}","deployments_url":"https://api.github.com/repos/dshanske/wordpress-micropub/deployments","created_at":"2015-02-13T01:41:50Z","updated_at":"2018-07-10T03:57:07Z","pushed_at":"2018-07-11T03:06:54Z","git_url":"git://github.com/dshanske/wordpress-micropub.git","ssh_url":"git@github.com:dshanske/wordpress-micropub.git","clone_url":"https://github.com/dshanske/wordpress-micropub.git","svn_url":"https://github.com/dshanske/wordpress-micropub","homepage":null,"size":320,"stargazers_count":1,"watchers_count":1,"language":"PHP","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"snarfed:master","ref":"master","sha":"3d9e5b6e1903a8d9777ba76b1e835646dfe7c122","user":{"login":"snarfed","id":778068,"node_id":"MDQ6VXNlcjc3ODA2OA==","avatar_url":"https://avatars2.githubusercontent.com/u/778068?v=4","gravatar_id":"","url":"https://api.github.com/users/snarfed","html_url":"https://github.com/snarfed","followers_url":"https://api.github.com/users/snarfed/followers","following_url":"https://api.github.com/users/snarfed/following{/other_user}","gists_url":"https://api.github.com/users/snarfed/gists{/gist_id}","starred_url":"https://api.github.com/users/snarfed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snarfed/subscriptions","organizations_url":"https://api.github.com/users/snarfed/orgs","repos_url":"https://api.github.com/users/snarfed/repos","events_url":"https://api.github.com/users/snarfed/events{/privacy}","received_events_url":"https://api.github.com/users/snarfed/received_events","type":"User","site_admin":false},"repo":{"id":30504958,"node_id":"MDEwOlJlcG9zaXRvcnkzMDUwNDk1OA==","name":"wordpress-micropub","full_name":"snarfed/wordpress-micropub","owner":{"login":"snarfed","id":778068,"node_id":"MDQ6VXNlcjc3ODA2OA==","avatar_url":"https://avatars2.githubusercontent.com/u/778068?v=4","gravatar_id":"","url":"https://api.github.com/users/snarfed","html_url":"https://github.com/snarfed","followers_url":"https://api.github.com/users/snarfed/followers","following_url":"https://api.github.com/users/snarfed/following{/other_user}","gists_url":"https://api.github.com/users/snarfed/gists{/gist_id}","starred_url":"https://api.github.com/users/snarfed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snarfed/subscriptions","organizations_url":"https://api.github.com/users/snarfed/orgs","repos_url":"https://api.github.com/users/snarfed/repos","events_url":"https://api.github.com/users/snarfed/events{/privacy}","received_events_url":"https://api.github.com/users/snarfed/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/snarfed/wordpress-micropub","description":"A Micropub server plugin for WordPress","fork":false,"url":"https://api.github.com/repos/snarfed/wordpress-micropub","forks_url":"https://api.github.com/repos/snarfed/wordpress-micropub/forks","keys_url":"https://api.github.com/repos/snarfed/wordpress-micropub/keys{/key_id}","collaborators_url":"https://api.github.com/repos/snarfed/wordpress-micropub/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/snarfed/wordpress-micropub/teams","hooks_url":"https://api.github.com/repos/snarfed/wordpress-micropub/hooks","issue_events_url":"https://api.github.com/repos/snarfed/wordpress-micropub/issues/events{/number}","events_url":"https://api.github.com/repos/snarfed/wordpress-micropub/events","assignees_url":"https://api.github.com/repos/snarfed/wordpress-micropub/assignees{/user}","branches_url":"https://api.github.com/repos/snarfed/wordpress-micropub/branches{/branch}","tags_url":"https://api.github.com/repos/snarfed/wordpress-micropub/tags","blobs_url":"https://api.github.com/repos/snarfed/wordpress-micropub/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/snarfed/wordpress-micropub/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/snarfed/wordpress-micropub/git/refs{/sha}","trees_url":"https://api.github.com/repos/snarfed/wordpress-micropub/git/trees{/sha}","statuses_url":"https://api.github.com/repos/snarfed/wordpress-micropub/statuses/{sha}","languages_url":"https://api.github.com/repos/snarfed/wordpress-micropub/languages","stargazers_url":"https://api.github.com/repos/snarfed/wordpress-micropub/stargazers","contributors_url":"https://api.github.com/repos/snarfed/wordpress-micropub/contributors","subscribers_url":"https://api.github.com/repos/snarfed/wordpress-micropub/subscribers","subscription_url":"https://api.github.com/repos/snarfed/wordpress-micropub/subscription","commits_url":"https://api.github.com/repos/snarfed/wordpress-micropub/commits{/sha}","git_commits_url":"https://api.github.com/repos/snarfed/wordpress-micropub/git/commits{/sha}","comments_url":"https://api.github.com/repos/snarfed/wordpress-micropub/comments{/number}","issue_comment_url":"https://api.github.com/repos/snarfed/wordpress-micropub/issues/comments{/number}","contents_url":"https://api.github.com/repos/snarfed/wordpress-micropub/contents/{+path}","compare_url":"https://api.github.com/repos/snarfed/wordpress-micropub/compare/{base}...{head}","merges_url":"https://api.github.com/repos/snarfed/wordpress-micropub/merges","archive_url":"https://api.github.com/repos/snarfed/wordpress-micropub/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/snarfed/wordpress-micropub/downloads","issues_url":"https://api.github.com/repos/snarfed/wordpress-micropub/issues{/number}","pulls_url":"https://api.github.com/repos/snarfed/wordpress-micropub/pulls{/number}","milestones_url":"https://api.github.com/repos/snarfed/wordpress-micropub/milestones{/number}","notifications_url":"https://api.github.com/repos/snarfed/wordpress-micropub/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/snarfed/wordpress-micropub/labels{/name}","releases_url":"https://api.github.com/repos/snarfed/wordpress-micropub/releases{/id}","deployments_url":"https://api.github.com/repos/snarfed/wordpress-micropub/deployments","created_at":"2015-02-08T20:39:22Z","updated_at":"2018-07-10T03:54:14Z","pushed_at":"2018-07-11T03:18:54Z","git_url":"git://github.com/snarfed/wordpress-micropub.git","ssh_url":"git@github.com:snarfed/wordpress-micropub.git","clone_url":"https://github.com/snarfed/wordpress-micropub.git","svn_url":"https://github.com/snarfed/wordpress-micropub","homepage":null,"size":289,"stargazers_count":29,"watchers_count":29,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"archived":false,"open_issues_count":20,"license":null,"forks":8,"open_issues":20,"watchers":29,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/snarfed/wordpress-micropub/pulls/135"},"html":{"href":"https://github.com/snarfed/wordpress-micropub/pull/135"},"issue":{"href":"https://api.github.com/repos/snarfed/wordpress-micropub/issues/135"},"comments":{"href":"https://api.github.com/repos/snarfed/wordpress-micropub/issues/135/comments"},"review_comments":{"href":"https://api.github.com/repos/snarfed/wordpress-micropub/pulls/135/comments"},"review_comment":{"href":"https://api.github.com/repos/snarfed/wordpress-micropub/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/snarfed/wordpress-micropub/pulls/135/commits"},"statuses":{"href":"https://api.github.com/repos/snarfed/wordpress-micropub/statuses/7d784c33f3e710ff81efaa35b6379132fba4612f"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"snarfed"}}