{"action":"created","comment":{"url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/pulls/comments/71195758","id":71195758,"diff_hunk":"@@ -0,0 +1,174 @@\n+<?php\n+\n+/**\n+ * Plugin Name: b2c_authentication\n+ * Plugin URI: https://github.com/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect\n+ * Description: A plugin that allows users to log in using B2C policies\n+ * Version: 1.0\n+ * Author: Olena Huang\n+ */\n+\n+////////////////////////////////////////////////////////////////////////////////\n+\n+// Turn on error reporting, for debugging\n+error_reporting(E_ALL);\n+\n+// Adds the b2c options page for the admin\n+require_once 'settings_page.php';\n+\n+// On user login, redirects to B2C\n+function b2c_login() {\n+\t\n+\trequire_once 'settings.php';\n+\trequire_once 'EndpointHandler.php';\n+\t\n+\t// Redirect to sign up/sign in page\n+\t$endpoint_handler = new EndpointHandler($generic_policy);\n+\t$authorization_endpoint = $endpoint_handler->getAuthorizationEndpoint().\"&state=generic\";\n+\twp_redirect($authorization_endpoint);\n+\texit;\n+}\n+\n+// On user logout, redirects to B2C\n+function b2c_logout() {\n+\t\n+\trequire_once 'settings.php';\n+\trequire_once 'EndpointHandler.php';\n+\t\n+\t// Redirect to logout page\n+\t$signout_endpoint_handler = new EndpointHandler($generic_policy);\n+\t$signout_uri = $signout_endpoint_handler->getEndSessionEndpoint();\n+\twp_redirect($signout_uri);\n+\texit;\n+}\n+\n+// Verifies the id_token that is POSTed back to the web app from the B2C authorization endpoint\n+function b2c_verify_token() {\n+\t\n+\t// If and only if ID token is POSTed to the /b2c-token-verification path, \n+\t// proceeds with verifying the ID token. The path check ensures that other plugins\n+\t// which may POST id tokens do not conflict with this plugin.\n+\t$pagename = $_SERVER['REQUEST_URI'];\n+\tif ($pagename == '/b2c-token-verification' && isset($_POST['id_token'])) {\n+\t\t\n+\t\trequire_once 'settings.php';\n+\t\trequire_once 'TokenChecker.php';\n+\t\t\n+\t\t// Check which authorization policy was used\n+\t\t$action = $_POST['state'];\n+\t\tif ($action == \"generic\") $policy = $generic_policy;\n+\t\tif ($action == \"admin\") $policy = $admin_policy;\n+\t\tif ($action == \"edit_profile\") $policy = $edit_profile_policy;","path":"b2c_authentication.php","position":61,"original_position":61,"commit_id":"331fc58ba3f6d29c338feda1a516fdd171d85ab7","original_commit_id":"331fc58ba3f6d29c338feda1a516fdd171d85ab7","user":{"login":"zhunling","id":10622035,"avatar_url":"https://avatars.githubusercontent.com/u/10622035?v=3","gravatar_id":"","url":"https://api.github.com/users/zhunling","html_url":"https://github.com/zhunling","followers_url":"https://api.github.com/users/zhunling/followers","following_url":"https://api.github.com/users/zhunling/following{/other_user}","gists_url":"https://api.github.com/users/zhunling/gists{/gist_id}","starred_url":"https://api.github.com/users/zhunling/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zhunling/subscriptions","organizations_url":"https://api.github.com/users/zhunling/orgs","repos_url":"https://api.github.com/users/zhunling/repos","events_url":"https://api.github.com/users/zhunling/events{/privacy}","received_events_url":"https://api.github.com/users/zhunling/received_events","type":"User","site_admin":false},"body":"switch?","created_at":"2016-07-18T17:55:00Z","updated_at":"2016-07-18T17:55:00Z","html_url":"https://github.com/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/pull/3#discussion_r71195758","pull_request_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/pulls/comments/71195758"},"html":{"href":"https://github.com/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/pull/3#discussion_r71195758"},"pull_request":{"href":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/pulls/3","id":77530689,"html_url":"https://github.com/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/pull/3","diff_url":"https://github.com/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/pull/3.diff","patch_url":"https://github.com/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/pull/3.patch","issue_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/issues/3","number":3,"state":"open","locked":false,"title":"Add files for reivew","user":{"login":"zhunling","id":10622035,"avatar_url":"https://avatars.githubusercontent.com/u/10622035?v=3","gravatar_id":"","url":"https://api.github.com/users/zhunling","html_url":"https://github.com/zhunling","followers_url":"https://api.github.com/users/zhunling/followers","following_url":"https://api.github.com/users/zhunling/following{/other_user}","gists_url":"https://api.github.com/users/zhunling/gists{/gist_id}","starred_url":"https://api.github.com/users/zhunling/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zhunling/subscriptions","organizations_url":"https://api.github.com/users/zhunling/orgs","repos_url":"https://api.github.com/users/zhunling/repos","events_url":"https://api.github.com/users/zhunling/events{/privacy}","received_events_url":"https://api.github.com/users/zhunling/received_events","type":"User","site_admin":false},"body":"Add files for reivew","created_at":"2016-07-14T21:39:23Z","updated_at":"2016-07-18T17:55:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"576f0cc52a5fc7475383782a25d1596f70fc3a18","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/pulls/3/commits","review_comments_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/pulls/3/comments","review_comment_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/pulls/comments{/number}","comments_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/issues/3/comments","statuses_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/statuses/331fc58ba3f6d29c338feda1a516fdd171d85ab7","head":{"label":"zhunling:empty","ref":"empty","sha":"331fc58ba3f6d29c338feda1a516fdd171d85ab7","user":{"login":"zhunling","id":10622035,"avatar_url":"https://avatars.githubusercontent.com/u/10622035?v=3","gravatar_id":"","url":"https://api.github.com/users/zhunling","html_url":"https://github.com/zhunling","followers_url":"https://api.github.com/users/zhunling/followers","following_url":"https://api.github.com/users/zhunling/following{/other_user}","gists_url":"https://api.github.com/users/zhunling/gists{/gist_id}","starred_url":"https://api.github.com/users/zhunling/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zhunling/subscriptions","organizations_url":"https://api.github.com/users/zhunling/orgs","repos_url":"https://api.github.com/users/zhunling/repos","events_url":"https://api.github.com/users/zhunling/events{/privacy}","received_events_url":"https://api.github.com/users/zhunling/received_events","type":"User","site_admin":false},"repo":{"id":63369559,"name":"active-directory-b2c-wordpress-plugin-openidconnect","full_name":"zhunling/active-directory-b2c-wordpress-plugin-openidconnect","owner":{"login":"zhunling","id":10622035,"avatar_url":"https://avatars.githubusercontent.com/u/10622035?v=3","gravatar_id":"","url":"https://api.github.com/users/zhunling","html_url":"https://github.com/zhunling","followers_url":"https://api.github.com/users/zhunling/followers","following_url":"https://api.github.com/users/zhunling/following{/other_user}","gists_url":"https://api.github.com/users/zhunling/gists{/gist_id}","starred_url":"https://api.github.com/users/zhunling/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zhunling/subscriptions","organizations_url":"https://api.github.com/users/zhunling/orgs","repos_url":"https://api.github.com/users/zhunling/repos","events_url":"https://api.github.com/users/zhunling/events{/privacy}","received_events_url":"https://api.github.com/users/zhunling/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/zhunling/active-directory-b2c-wordpress-plugin-openidconnect","description":"A plugin for WordPress that allows users to authenticate with Azure AD B2C using OpenID Connect.","fork":true,"url":"https://api.github.com/repos/zhunling/active-directory-b2c-wordpress-plugin-openidconnect","forks_url":"https://api.github.com/repos/zhunling/active-directory-b2c-wordpress-plugin-openidconnect/forks","keys_url":"https://api.github.com/repos/zhunling/active-directory-b2c-wordpress-plugin-openidconnect/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zhunling/active-directory-b2c-wordpress-plugin-openidconnect/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zhunling/active-directory-b2c-wordpress-plugin-openidconnect/teams","hooks_url":"https://api.github.com/repos/zhunling/active-directory-b2c-wordpress-plugin-openidconnect/hooks","issue_events_url":"https://api.github.com/repos/zhunling/active-directory-b2c-wordpress-plugin-openidconnect/issues/events{/number}","events_url":"https://api.github.com/repos/zhunling/active-directory-b2c-wordpress-plugin-openidconnect/events","assignees_url":"https://api.github.com/repos/zhunling/active-directory-b2c-wordpress-plugin-openidconnect/assignees{/user}","branches_url":"https://api.github.com/repos/zhunling/active-directory-b2c-wordpress-plugin-openidconnect/branches{/branch}","tags_url":"https://api.github.com/repos/zhunling/active-directory-b2c-wordpress-plugin-openidconnect/tags","blobs_url":"https://api.github.com/repos/zhunling/active-directory-b2c-wordpress-plugin-openidconnect/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zhunling/active-directory-b2c-wordpress-plugin-openidconnect/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zhunling/active-directory-b2c-wordpress-plugin-openidconnect/git/refs{/sha}","trees_url":"https://api.github.com/repos/zhunling/active-directory-b2c-wordpress-plugin-openidconnect/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zhunling/active-directory-b2c-wordpress-plugin-openidconnect/statuses/{sha}","languages_url":"https://api.github.com/repos/zhunling/active-directory-b2c-wordpress-plugin-openidconnect/languages","stargazers_url":"https://api.github.com/repos/zhunling/active-directory-b2c-wordpress-plugin-openidconnect/stargazers","contributors_url":"https://api.github.com/repos/zhunling/active-directory-b2c-wordpress-plugin-openidconnect/contributors","subscribers_url":"https://api.github.com/repos/zhunling/active-directory-b2c-wordpress-plugin-openidconnect/subscribers","subscription_url":"https://api.github.com/repos/zhunling/active-directory-b2c-wordpress-plugin-openidconnect/subscription","commits_url":"https://api.github.com/repos/zhunling/active-directory-b2c-wordpress-plugin-openidconnect/commits{/sha}","git_commits_url":"https://api.github.com/repos/zhunling/active-directory-b2c-wordpress-plugin-openidconnect/git/commits{/sha}","comments_url":"https://api.github.com/repos/zhunling/active-directory-b2c-wordpress-plugin-openidconnect/comments{/number}","issue_comment_url":"https://api.github.com/repos/zhunling/active-directory-b2c-wordpress-plugin-openidconnect/issues/comments{/number}","contents_url":"https://api.github.com/repos/zhunling/active-directory-b2c-wordpress-plugin-openidconnect/contents/{+path}","compare_url":"https://api.github.com/repos/zhunling/active-directory-b2c-wordpress-plugin-openidconnect/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zhunling/active-directory-b2c-wordpress-plugin-openidconnect/merges","archive_url":"https://api.github.com/repos/zhunling/active-directory-b2c-wordpress-plugin-openidconnect/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zhunling/active-directory-b2c-wordpress-plugin-openidconnect/downloads","issues_url":"https://api.github.com/repos/zhunling/active-directory-b2c-wordpress-plugin-openidconnect/issues{/number}","pulls_url":"https://api.github.com/repos/zhunling/active-directory-b2c-wordpress-plugin-openidconnect/pulls{/number}","milestones_url":"https://api.github.com/repos/zhunling/active-directory-b2c-wordpress-plugin-openidconnect/milestones{/number}","notifications_url":"https://api.github.com/repos/zhunling/active-directory-b2c-wordpress-plugin-openidconnect/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zhunling/active-directory-b2c-wordpress-plugin-openidconnect/labels{/name}","releases_url":"https://api.github.com/repos/zhunling/active-directory-b2c-wordpress-plugin-openidconnect/releases{/id}","deployments_url":"https://api.github.com/repos/zhunling/active-directory-b2c-wordpress-plugin-openidconnect/deployments","created_at":"2016-07-14T21:02:53Z","updated_at":"2016-07-14T21:02:54Z","pushed_at":"2016-07-14T21:37:12Z","git_url":"git://github.com/zhunling/active-directory-b2c-wordpress-plugin-openidconnect.git","ssh_url":"git@github.com:zhunling/active-directory-b2c-wordpress-plugin-openidconnect.git","clone_url":"https://github.com/zhunling/active-directory-b2c-wordpress-plugin-openidconnect.git","svn_url":"https://github.com/zhunling/active-directory-b2c-wordpress-plugin-openidconnect","homepage":null,"size":264,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"AzureAD:empty1","ref":"empty1","sha":"cc0e247f2dac55cdfc71eb58780a70e35c0d5883","user":{"login":"AzureAD","id":2966316,"avatar_url":"https://avatars.githubusercontent.com/u/2966316?v=3","gravatar_id":"","url":"https://api.github.com/users/AzureAD","html_url":"https://github.com/AzureAD","followers_url":"https://api.github.com/users/AzureAD/followers","following_url":"https://api.github.com/users/AzureAD/following{/other_user}","gists_url":"https://api.github.com/users/AzureAD/gists{/gist_id}","starred_url":"https://api.github.com/users/AzureAD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AzureAD/subscriptions","organizations_url":"https://api.github.com/users/AzureAD/orgs","repos_url":"https://api.github.com/users/AzureAD/repos","events_url":"https://api.github.com/users/AzureAD/events{/privacy}","received_events_url":"https://api.github.com/users/AzureAD/received_events","type":"Organization","site_admin":false},"repo":{"id":62092576,"name":"active-directory-b2c-wordpress-plugin-openidconnect","full_name":"AzureAD/active-directory-b2c-wordpress-plugin-openidconnect","owner":{"login":"AzureAD","id":2966316,"avatar_url":"https://avatars.githubusercontent.com/u/2966316?v=3","gravatar_id":"","url":"https://api.github.com/users/AzureAD","html_url":"https://github.com/AzureAD","followers_url":"https://api.github.com/users/AzureAD/followers","following_url":"https://api.github.com/users/AzureAD/following{/other_user}","gists_url":"https://api.github.com/users/AzureAD/gists{/gist_id}","starred_url":"https://api.github.com/users/AzureAD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AzureAD/subscriptions","organizations_url":"https://api.github.com/users/AzureAD/orgs","repos_url":"https://api.github.com/users/AzureAD/repos","events_url":"https://api.github.com/users/AzureAD/events{/privacy}","received_events_url":"https://api.github.com/users/AzureAD/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect","description":"A plugin for WordPress that allows users to authenticate with Azure AD B2C using OpenID Connect.","fork":false,"url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect","forks_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/forks","keys_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/teams","hooks_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/hooks","issue_events_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/issues/events{/number}","events_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/events","assignees_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/assignees{/user}","branches_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/branches{/branch}","tags_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/tags","blobs_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/git/refs{/sha}","trees_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/statuses/{sha}","languages_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/languages","stargazers_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/stargazers","contributors_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/contributors","subscribers_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/subscribers","subscription_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/subscription","commits_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/commits{/sha}","git_commits_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/git/commits{/sha}","comments_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/comments{/number}","issue_comment_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/issues/comments{/number}","contents_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/contents/{+path}","compare_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/merges","archive_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/downloads","issues_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/issues{/number}","pulls_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/pulls{/number}","milestones_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/milestones{/number}","notifications_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/labels{/name}","releases_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/releases{/id}","deployments_url":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/deployments","created_at":"2016-06-27T22:27:08Z","updated_at":"2016-07-12T21:19:40Z","pushed_at":"2016-07-15T21:05:05Z","git_url":"git://github.com/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect.git","ssh_url":"git@github.com:AzureAD/active-directory-b2c-wordpress-plugin-openidconnect.git","clone_url":"https://github.com/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect.git","svn_url":"https://github.com/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect","homepage":null,"size":265,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":1,"forks":2,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/pulls/3"},"html":{"href":"https://github.com/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/pull/3"},"issue":{"href":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/issues/3"},"comments":{"href":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/AzureAD/active-directory-b2c-wordpress-plugin-openidconnect/statuses/331fc58ba3f6d29c338feda1a516fdd171d85ab7"}}}}
{"actor":{"display_login":"zhunling"}}