From 00d59edb0804583c788996416e22b633ab7bd3fc Mon Sep 17 00:00:00 2001 From: Mark Sauer Date: Sat, 15 Dec 2018 20:56:39 +0800 Subject: [PATCH] Initial commit --- gotomyaccounts-sso.zip | Bin 0 -> 4871 bytes gotomyaccounts-sso/gotomyaccounts-sso.php | 39 ++++ gotomyaccounts-sso/includes/gtma-init.php | 110 +++++++++ gotomyaccounts-sso/includes/gtma-settings.php | 210 ++++++++++++++++++ gotomyaccounts-sso/includes/index.php | 2 + gotomyaccounts-sso/index.php | 2 + 6 files changed, 363 insertions(+) create mode 100644 gotomyaccounts-sso.zip create mode 100644 gotomyaccounts-sso/gotomyaccounts-sso.php create mode 100644 gotomyaccounts-sso/includes/gtma-init.php create mode 100644 gotomyaccounts-sso/includes/gtma-settings.php create mode 100644 gotomyaccounts-sso/includes/index.php create mode 100644 gotomyaccounts-sso/index.php diff --git a/gotomyaccounts-sso.zip b/gotomyaccounts-sso.zip new file mode 100644 index 0000000000000000000000000000000000000000..0d37a846b174727ea7577acc3ec68bdc86302d07 GIT binary patch literal 4871 zcma)=1yq#V_P_^_Zl$}CE&+j|Q5uG3D2ah#5ExRrq!~d}? zMB(B8y?cHCb-nMs^R4fk@7rsg-#Pp2z4qGsfYdQ=kpTbz9DurKl16!^7+pCU0PqL{ z0N}cjLg5~8Cm$;t8@Q*lhdZCUJ6zzeB7PTpm)Im7?FB)y@DbP_c-mW=egfBb2(tT^d-1*1rdf0 z%`dalI$wa(_svJrs2dcG)t0!|7%L-8=|AF!3=b}=7C^_0Pu1N*f>|R&L}*U7P8tCZ z{l4jO?*dl|?|v6d5jV74%?^H5o2RjWCliNFMv;X^)}WW8E0y;Qv$f>F!sd27;YW>~ zuf8_)2DVY>=El!ZGRY-dFmF9#XPZx-JtA=zS4N;Uu2ubD1E;2iI#G)!%DDrH>HK5( z17Uq2z53w#(g3q?jxCxKFSCjw3gGD8=uojmz)%c}CPNoP@HyX-PXus?Yyo~;t{9!m>b=SPLGP4TV*|C9wyz1d#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*#<$`Kq)gsb3CZKsnG(5(^m8l`)HRwuJw1=H(+aJ<=YZs@!a;RL z5t{capKJ6k2bEUsbZfSh&BV7w_ae%A&U`RPPT-}=q$8@^WwE^wy}i6RuJjN2c%B~& zaIwb*6bDZXM;bk6i$!$>U$|BZm1{!hj4kPV4iQsjRv+%8Z`DSbDG=w}%}jYYNS(Y# z(b_jMpP3+DHz(IwYa&skp%z;SZj=n|%tLqIh+)Vf)f!R)UMj?63_(?tq4MD&Ko$gZ z$tP^Tilz?3gSWXMcP+49@PE@pi;B@Z%AG(%seeWqReBpQu{!p_qebwVaRcIg~EdT zRd&or2^32++q-ATg|s~nc4Q0`IS}Th)LQn^d6`x>^~Bj#>cFt$zT#WDCzgDJL^2+) z2k$c#4$hWOP`z!uMB!t4Nxnj&k|2H4&oc%nUR*)QDQCU;VstY?$tC%$%l5pnKdgGM zEJZ-8!B4gm#I}}4Hr4tvJEuN7T6;jUH;v);-BkOjO%(xnn3!!Xtal{AuBKKspOexn z+`E>QDc?mnYL1I)So+51wV8PLYY(^!qpq$95?JXR;v=wVN+)V-a4r1^AG*h@l5dso z|;R`IR7^a?4 zsdZSbSnqjeD|_M+*J3=LKl~;o3(N6u&fg{bh|XrV9vOi){S^@4cVFcByl~D(=)4Va zopu=RNKVPZowheE$g4S7f%T6K9o4N{0(GijnkuY|3{Lhu+dShVnxHOBKaNOg#~)d) za!C3IjSt56MSRN@cNklmf*SRV+^8(A%x4(;ukioKya0fb@?Ir164J|`73I&D{l8>h zFlUIZ_s@(AD0|c42?#Lh!5nR!ZETrf?o3d)BgEF3AMfw+KbQDz;rc&O(a^~Ne}4sX zg9e}hn0^j7?Ki9ZRrFI4koq6k-`Cmy#F5+#CpY&ke`Wl8)%^$Q_jUJA(myxIi~gTU z|E~)FwLu)f?-J!-*a@uv0sHT1^Dp%8J>eHxuser_email; + if ($portalURL != '' && $sso_password != '') + { + try + { + $url = "https://appapi.gotomyaccounts.com/v1/SSO/?email=" . urlencode($email) . "&portal_hostname=" . urlencode($portalURL); + $args = array( + 'method' => 'GET', + 'timeout' => 60, + 'sslverify' => false, + 'headers' => array( "Authorization" => $sso_password ), + 'body' => array(), + 'cookies' => false + ); + $response = wp_safe_remote_get($url, $args); + if (!is_wp_error($response)) + { + $result = $response['response']; + if ($result['code'] == 200 && $result['message'] == 'OK') + { + $token = $response['body']; + } else + { + $token = ''; + } + } else + { + $token = ''; + } + } catch (Exception $exc) + { + $token = ''; + } + } + return $token; + } + + function gtma_redirect() + { + $gtma_redirects = get_option('gtma_sso_redirects', array()); + $ids = array_keys($gtma_redirects); + $token = $this->get_token(); + $portalURL = get_option('gtma_portal_url', ''); + $id = get_the_ID(); + if ((in_array($id, $ids)) && !empty($token) && !empty($portalURL)) + { + $link = "https://" . $portalURL . "/sso?token=" . urlencode($token) . "&page=" . $gtma_redirects[$id]; + wp_redirect($link); + exit; + } + } + +} \ No newline at end of file diff --git a/gotomyaccounts-sso/includes/gtma-settings.php b/gotomyaccounts-sso/includes/gtma-settings.php new file mode 100644 index 0000000..12749d3 --- /dev/null +++ b/gotomyaccounts-sso/includes/gtma-settings.php @@ -0,0 +1,210 @@ +ID] = $page->post_title; +} +?> + + +
+ logo +

GoToMyAccounts Single Sign On Settings

+
+
+ +
+

+ Quick-Start Instructions +

+ Note: In order for SSO to work, your logged in WordPress user must have a corresponding web portal account with the exact same email address. +
    +
  1. Set your web portal address and SSO token
  2. +
  3. + Create empty pages for the portal redirects you desire. (Ex: Billing, Make a payment, Manage Users, etc)
    + (These represent a single "deep link" into your web portal) +
  4. +
  5. Add your pages (links) to one or menus.
  6. +
  7. Click a menu item to test.
  8. +
+

+ Full Documentation +

+
+
+ +
+
"> + + + + + + + + + + + + + + + +
+ + + +

+ Set your GoToMyAccounts portal URL (no http/https or trailing "/").
+ Example: myportal.gotomyaccounts.com +

+
+ + + +

+ Where do I find this? You can manage your SSO tokens from within your portal (when logged in with admin permissions). On the left + menu, click Integrations, then click "SSO Tokens". Copy a token from that page and paste it into this field. +

+
+ Add Redirect + + + +
+ Actual Wordpress pages should not contain any content. The plugin will cause these pages to redirect instead to your Web Portal Redirect Page.
+ If the redirect fails, the page will instead display an error message to the user.
+ Example Web Portal Redirect Pages: "customer_dashboard.html", "payment.html", "customer_manage_users.html" +
+ +
+ + + + + + + +
Redirected Page + + + + + + + + + + $redirect) + { + if ($id) + { + ?> + + + + + + + + + + + +
WordPress Page (should be empty)Web Portal Redirect PageActions
+ + ">
No Redirects Configured
+
+
+
\ No newline at end of file diff --git a/gotomyaccounts-sso/includes/index.php b/gotomyaccounts-sso/includes/index.php new file mode 100644 index 0000000..6220032 --- /dev/null +++ b/gotomyaccounts-sso/includes/index.php @@ -0,0 +1,2 @@ +