Changeset 1787610
- Timestamp:
- 12/15/2017 12:54:20 PM (8 years ago)
- Location:
- yoti/trunk
- Files:
-
- 10 edited
-
README.md (modified) (2 diffs)
-
YotiAdmin.php (modified) (3 diffs)
-
YotiHelper.php (modified) (1 diff)
-
YotiWidget.php (modified) (5 diffs)
-
assets/styles.css (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
-
sdk/Yoti/YotiClient.php (modified) (2 diffs)
-
views/admin-options.php (modified) (3 diffs)
-
views/profile.php (modified) (1 diff)
-
yoti.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
yoti/trunk/README.md
r1760739 r1787610 1 # Yoti Word press SDK #1 # Yoti WordPress Plugin 2 2 3 Welcome to the Yoti Wordpress SDK. This repo contains the tools you need to quickly integrate your Wordpress back-end with Yoti, so that your users can share their identity details with your application in a secure and trusted way. 4 5 ## Table of Contents 6 7 1) [An Architectural view](#an-architectural-view) - 8 High level overview of integration 9 10 2) [References](#references)- 11 Guides before you start 12 13 3) [Requirements](#requirements)- 14 Everything you need to get started 15 16 4) [Installing the SDK](#installing-the-sdk)- 17 How to install our SDK 18 19 5) [Plugin Setup](#plugin-setup)- 20 How to set up the plugin in Wordpress 21 22 6) [Setting up your Yoti Application](#setting-up-your-yoti-application)- 23 Setting up your Yoti Application in Wordpress 24 25 7) [Allowing new registrations](#allowing-new-registrations)- 26 Extra features in WordPress 27 28 8) [Linking existing accounts to use Yoti authentication](#linking-existing-accounts-to-use-yoti-authentication) 29 30 9) [API Coverage](#api-coverage)- 31 Attributes defined 32 33 10) [Support](#support)- 34 Please feel free to reach out 35 36 ## An Architectural view 37 38 Before you start your integration, here is a bit of background on how the integration works. To integrate your application with Yoti, your back-end must expose a GET endpoint that Yoti will use to forward tokens. 39 The endpoint can be configured in the Yoti Dashboard when you create/update your application. For more information on how to create an application please check our [developer page](https://www.yoti.com/developers/documentation/#login-button-setup). 40 41 The image below shows how your application back-end and Yoti integrate into the context of a Login flow. 42 Yoti SDK carries out for you steps 6, 7 and the profile decryption in step 8. 43 44  45 46 47 Yoti also allows you to enable user details verification from your mobile app by means of the Android (TBA) and iOS (TBA) SDKs. In that scenario, your Yoti-enabled mobile app is playing both the role of the browser and the Yoti app. Your back-end doesn't need to handle these cases in a significantly different way. You might just decide to handle the `User-Agent` header in order to provide different responses for desktop and mobile clients. 48 49 ## References 50 51 * [AES-256 symmetric encryption][] 52 * [RSA pkcs asymmetric encryption][] 53 * [Protocol buffers][] 54 * [Base64 data][] 55 56 [AES-256 symmetric encryption]: https://en.wikipedia.org/wiki/Advanced_Encryption_Standard 57 [RSA pkcs asymmetric encryption]: https://en.wikipedia.org/wiki/RSA_(cryptosystem) 58 [Protocol buffers]: https://en.wikipedia.org/wiki/Protocol_Buffers 59 [Base64 data]: https://en.wikipedia.org/wiki/Base64 3 This repository contains the tools you need to quickly integrate your WordPress backend with Yoti, so that your users can share their identity details with your application in a secure and trusted way. The plugin uses the Yoti PHP SDK. If you're interested in finding out more about the SDK, click [here](https://github.com/getyoti/yoti-php-sdk). 60 4 61 5 ## Requirements 62 6 63 This SDK works with the WordPress business plan package.7 This SDK works with the WordPress Business Plan package. 64 8 65 9 ## Installing the SDK 10 66 11 You can install the Yoti SDK in two ways: 67 12 68 ### By importing the Yoti SDK inside your project :13 ### By importing the Yoti SDK inside your project 69 14 70 1 ) Log on to the admin console of your Wordpress website. e.g. Https://www.wordpressurl.org.uk/wp-admin71 2 ) Navigate to at `Plugins > Add New`.72 3 ) Search for Yoti and install and activate the plug in.15 1. Log on to your Wordpress Admin Dashboard e.g. https://www.wordpressurl.org.uk/wp-admin 16 2. Navigate to `Plugins > Add New` 17 3. Search for Yoti, install and activate the plugin 73 18 74 ### By using this repos (For Mac &Linux users)19 ### By using this repository (For MacOS and Linux users) 75 20 76 1 ) Download and unzip this repository, or, clone this repository77 2 ) Run `./pack-plugin.sh`. This will download the Yoti PHP SDK, and place it within the plugin directory.78 3 ) On completion of step 2, you will have a file called `yoti-wordpress-(version)-edge.zip`.79 4 ) Upload this file on WordPressat `Plugins > Add New`, then click `Upload Plugin`.80 5 ) Once installed, click`Activate Plugin`.21 1. Clone this repository 22 2. Run `./pack-plugin.sh`. This will download the Yoti PHP SDK and place it in the plugin directory 23 3. On completion of step 2, you will have a file called `yoti-wordpress-edge.zip`. 24 4. Upload this file in your Wordpress Admin Dashboard at `Plugins > Add New`, then click `Upload Plugin`. 25 5. Once installed, click on `Activate Plugin`. 81 26 82 27 ## Plugin Setup 83 28 84 29 To set things up, navigate on WordPress to `Settings > Yoti`. 85 86 Here you will be asked to add the following information: 87 88 Yoti App ID 89 Yoti Scenario ID 30 You will be asked to add the following information: 90 31 91 Yoti SDK ID 32 * `Yoti App ID` is the unique identifier of your specific application. 33 * `Yoti Scenario ID` is used to render the inline QR code. 34 * `Yoti SDK ID` is the SDK identifier generated by Yoti Dashboard in the Key tab when you create your app. Note this is not your Application Identifier, which is needed by your client-side code. 35 * `Company Name` will replace WordPress wording in the warning message displayed on the custom login form. 36 * `Yoti PEM File` is the application pem file. It can be downloaded only once from the Keys tab in your Yoti Dashboard. 92 37 93 Company Name 94 95 Yoti PEM File 96 97 Where: 98 99 - `Yoti App ID` is unique identifier for your specific application. 100 101 - `Yoti Scenario ID` is used to render the inline QR code. 102 103 - `Yoti SDK ID` is the SDK identifier generated by Yoti Dashboard in the Key tab when you create your app. Note this is not your Application Identifier which is needed by your client-side code. 104 105 - `Company Name` this will replace WordPress wording in the warning message which is displayed on the custom login form. 106 107 - `Yoti PEM File` is the application pem file. It can be downloaded only once from the Keys tab in your Yoti Dashboard. 108 109 Please do not open the pem file as this might corrupt the key and you will need to create a new application. 38 Please do not open the .pem file as this might corrupt the key and you will need to create a new application. 110 39 111 40 ## Setting up your Yoti Application 112 41 113 Specify the basic details of your application such as the name, description and optional logo. These details can be whatever you like and will not affect the plugin s functionality.42 Specify the basic details of your application such as the name, description and optional logo. These details can be whatever you like and will not affect the plugin's functionality. 114 43 115 The `Data` tab - Specify any attributes you like, at this time, you must choose at least one. It is recommend you choose `Given Name(s)`, `Family Name` and `Email Address` at a minimum, if you plan to allow new user registrations.44 The `Data` tab - Specify any attributes you'd like users to share. You must select at least one. If you plan to allow new user registrations, we recommended choosing `Given Name(s)`, `Family Name` and `Email Address` at a minimum. 116 45 117 The `Integration` tab - Here is where you specify the callback URL. This is found on your WordPress settings page. __NOTE__: If you get redirected to your WordPress frontpage instead of the Admin area, simply add `/wp-admin` to the URL.46 The `Integration` tab - Here is where you specify the callback URL. This can be found on your Yoti settings page in your WordPress Admin Dashboard. **NOTE**: If you get redirected to your WordPress frontpage instead of the Admin area, simply add `/wp-admin` to the URL. 118 47 119 48 ## Allowing new registrations 120 121 By default, this is not enabled for security. Ticking the box and saving your changes allows a new user to Register and Log in by using thier Yoti.122 123 A new user who registeres this way will be set to the `Subscriber` role in WordPress.124 125 If left disabled, if a new user tries to scan the Yoti QR code, they will be redirected back to the login page with an error message displayed.126 49 127 ## API Coverage 50 `Only allow existing Wordpress users to link their Yoti account` - This setting allows a new user to Register and Log in by using their Yoti. A new user who registeres this way will be set to the `Subscriber` role in WordPress. If enabled, when a new user tries to scan the Yoti QR code, they will be redirected back to the login page with an error message displayed. 128 51 129 * Activity Details 130 * [X] User ID `user_id` 131 * [X] Profile 132 * [X] Photo `selfie` 133 * [X] Given Names `given_names` 134 * [X] Family Name `family_name` 135 * [X] Mobile Number `phone_number` 136 * [X] Email address `email_address` 137 * [X] Date of Birth `date_of_birth` 138 * [X] Address `postal_address` 139 * [X] Gender `gender` 140 * [X] Nationality `nationality` 52 `Attempt to link Yoti email address with Wordpress account for first time users` - This setting enables linking a Yoti account to a WordPress user if the email from both platforms is identical. 53 54 ## Docker 55 56 We provide a WordPress Docker container that includes the Yoti plugin. 57 58 ### Setup 59 60 To try out our Docker container, clone this repository and run the following commands: 61 62 Go to the directory where the repo was cloned: 63 64 ```shell 65 cd yoti-wordpress 66 ``` 67 68 Rebuild the images if you have modified the `docker-compose.yml` file: 69 70 ```shell 71 docker-compose build --no-cache 72 ``` 73 74 Build the containers: 75 76 ```shell 77 docker-compose up -d 78 ``` 79 80 After the command has finished running, go to [http://localhost:7000](http://localhost:7000) and follow the instructions. 81 82 The Yoti plugin will be installed alongside WordPress. Activate it and follow our [plugin setup process](#plugin-setup). 83 84 ### Removing the Docker containers 85 86 Run the following commands to remove docker containers: 87 88 ```shell 89 docker-compose stop 90 docker-compose rm 91 ``` 141 92 142 93 ## Support … … 145 96 Please provide the following the get you up and working as quick as possible: 146 97 147 - Computer Type 148 - OS Version 149 - Screenshot 150 151 98 * Computer Type 99 * OS Version 100 * Screenshot -
yoti/trunk/YotiAdmin.php
r1760739 r1787610 54 54 55 55 // Check curl has preliminary extensions to run 56 $errors = array();56 $errors = []; 57 57 if (!function_exists('curl_version')) 58 58 { … … 149 149 * @return null 150 150 */ 151 protected function postVar($var, $default = null)151 protected function postVar($var, $default = NULL) 152 152 { 153 153 return array_key_exists($var, $_POST) ? $_POST[$var] : $default; … … 156 156 /** 157 157 * @param $var 158 * @param null$default159 * @return null158 * @param NULL $default 159 * @return NULL 160 160 */ 161 protected function filesVar($var, $default = null)161 protected function filesVar($var, $default = NULL) 162 162 { 163 163 return (array_key_exists($var, $_FILES) && !empty($_FILES[$var]['name'])) ? $_FILES[$var] : $default; -
yoti/trunk/YotiHelper.php
r1760739 r1787610 17 17 */ 18 18 const YOTI_CONFIG_OPTION_NAME = 'yoti_config'; 19 20 /** 21 * Yoti SDK javascript library. 22 */ 23 const YOTI_SDK_JAVASCRIPT_LIBRARY = 'https://sdk.yoti.com/clients/browser.2.0.1.js'; 19 24 20 25 /** -
yoti/trunk/YotiWidget.php
r1760739 r1787610 3 3 class YotiWidget extends WP_Widget 4 4 { 5 const YOTI_WIDGET_DEFAULT_TITLE = 'Authenticate with Yoti'; 6 5 7 /** 6 8 * Register widget with WordPress. … … 8 10 public function __construct() 9 11 { 12 $widget_options = ['classname' => 'yoti_widget', 'description' => __('Yoti button')]; 10 13 parent::__construct( 11 'yoti _widget', // Base ID14 'yoti-widget', // Base ID 12 15 esc_html__('Yoti Widget'), // Name 13 ['description' => 'Yoti button']16 $widget_options 14 17 ); 15 18 } … … 25 28 public function widget($args, $instance) 26 29 { 30 if ( ! isset( $args['widget_id'] ) ) { 31 $args['widget_id'] = $this->id; 32 } 33 $title = (!empty( $instance['title'])) ? $instance['title'] : __(self::YOTI_WIDGET_DEFAULT_TITLE); 34 35 $title = apply_filters('widget_title', $title, $instance, $this->id_base); 36 27 37 wp_enqueue_style('yoti-asset-css', plugin_dir_url(__FILE__) . 'assets/styles.css'); 28 38 $config = YotiHelper::getConfig(); 39 $widgetTitleHtml = ''; 40 $widgetContent = '<strong>Yoti not configured.</strong>'; 41 // Apply widget title html 42 if(!empty($title)){ 43 $widgetTitleHtml = $args['before_title'] . $title . $args['after_title']; 44 } 29 45 if (!empty($config['yoti_sdk_id']) && !empty($config['yoti_pem']['contents'])) { 30 echo '<div class="yoti-connect-button">' . YotiButton::render(NULL, TRUE) . '</div>';46 $widgetContent = YotiButton::render(NULL, TRUE); 31 47 } 32 e lse {33 echo '<div class="yoti-missing-config"><p><strong>Yoti Connect not configured.</strong></p></div>';34 }48 echo $args['before_widget']; 49 echo $widgetTitleHtml . "<ul><li>$widgetContent</li></ul>"; 50 echo $args['after_widget']; 35 51 } 36 52 … … 44 60 public function form($instance) 45 61 { 46 $title = !empty($instance['title']) ? $instance['title'] : esc_html__('New title', 'text_domain');62 $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : ''; 47 63 ?> 48 64 <p> 49 <label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php esc_attr_e('Title:' , 'text_domain'); ?></label>50 <input class="widefat" id="<?php echo esc_attr($this->get_field_id('title')); ?>" name="<?php echo esc_attr($this->get_field_name('title')); ?>" type="text" value="<?php echo esc_attr($title); ?>">65 <label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php esc_attr_e('Title:'); ?></label> 66 <input class="widefat" id="<?php echo esc_attr($this->get_field_id('title')); ?>" name="<?php echo esc_attr($this->get_field_name('title')); ?>" type="text" value="<?php echo $title; ?>"> 51 67 </p> 52 68 <?php … … 66 82 { 67 83 $instance = []; 68 $instance['title'] = (!empty($new_instance['title'])) ? strip_tags($new_instance['title']) : '';84 $instance['title'] = sanitize_text_field($new_instance['title']); 69 85 70 86 return $instance; -
yoti/trunk/assets/styles.css
r1760739 r1787610 1 2 .yoti-connect { 3 margin-bottom: 10px; 1 /* ------------ WP default widget ------------- */ 2 .yoti_widget ul { 3 list-style: none; 4 margin: 0; 4 5 } 5 6 7 /* ------------ Yoti Button -------------------- */ 6 8 .yoti-connect .yoti-connect-button { 7 9 text-align: center; 8 10 display: inline-block; 9 11 padding: 5px 10px; 10 border: 1px solid #ccc;11 12 background: #0085ba; 12 13 border-radius: 3px; -
yoti/trunk/readme.txt
r1765116 r1787610 4 4 Tags: identity, verification, login, form, 2 factor, 2 step authentication, 2FA, access, privacy, authentication, security, sign in, two factor 5 5 Requires at least: 3.0.1 6 Tested up to: 4. 8.17 Stable tag: 1.1. 46 Tested up to: 4.9.1 7 Stable tag: 1.1.5 8 8 License: GNU v3 9 9 License URI: https://www.gnu.org/licenses/gpl.txt … … 88 88 Version Date Changes 89 89 90 91 1.1.5 2017/04/14 Integrate the new inline QR style for Yoti button. 92 Apply WordPress widget style to Yoti button widget. 93 90 94 1.1.4 2017/08/11 Integrate SDK identifier to track plugin usage. 91 95 Apply Yoti style to the unlink button. -
yoti/trunk/sdk/Yoti/YotiClient.php
r1760739 r1787610 27 27 const DASHBOARD_URL = 'https://www.yoti.com/dashboard'; 28 28 29 // Accepted HTTP header values for X-Yoti-SDK header 30 const YOTI_ACCEPTED_SDK_IDENTIFIERS = [ 29 /** 30 * Accepted HTTP header values for X-Yoti-SDK header. 31 * 32 * @var array 33 */ 34 protected $acceptedSDKIdentifiers = [ 31 35 'PHP', 32 36 'WordPress', … … 435 439 private function isValidSdkIdentifier($providedHeader) 436 440 { 437 if(in_array($providedHeader, self::YOTI_ACCEPTED_SDK_IDENTIFIERS, TRUE)) {441 if(in_array($providedHeader, $this->acceptedSDKIdentifiers, TRUE)) { 438 442 return TRUE; 439 443 } -
yoti/trunk/views/admin-options.php
r1760739 r1787610 5 5 * @var array $errors 6 6 */ 7 // Check if linking users by email address is set 8 $useEmailAddressCheckBox = !empty($data['yoti_user_email']) ? 'checked="checked"' : ''; 9 // Check if linking existing users only is set 10 $onlyExistingUserCheckBox = !empty($data['yoti_only_existing']) ? 'checked="checked"' : ''; 7 11 ?> 8 12 <div class="wrap"> … … 79 83 <th scope="row"></th> 80 84 <td> 81 <label><input type="checkbox" name="yoti_only_existing" value="1"<?php if (!empty($data['yoti_only_existing'])) { echo ' checked="checked"'; }?> /> Only allow existing Wordpress users to link their Yoti account</label>85 <label><input type="checkbox" name="yoti_only_existing" value="1"<?php echo $onlyExistingUserCheckBox ?> /> Only allow existing Wordpress users to link their Yoti account</label> 82 86 </td> 83 87 </tr> … … 85 89 <th scope="row"></th> 86 90 <td> 87 <label><input type="checkbox" name="yoti_user_email" value="1" <?php if (!empty($data['yoti_user_email'])) { echo ' checked="checked"'; }?> /> Attempt to link Yoti email address with Wordpress account for first time users</label>91 <label><input type="checkbox" name="yoti_user_email" value="1" <?php echo $useEmailAddressCheckBox ?> /> Attempt to link Yoti email address with Wordpress account for first time users</label> 88 92 </td> 89 93 </tr> -
yoti/trunk/views/profile.php
r1760739 r1787610 11 11 $isAdmin = in_array('administrator', $currentUser->roles, TRUE); 12 12 $userId = (!empty($_GET['user_id'])) ? $_GET['user_id'] : NULL; 13 14 // Set userId if admin user is viewing his own profile 15 // and the userId is NULL 16 if( 17 $isAdmin 18 && $profileUserId === $currentUser->ID 19 && is_null($userId) 20 ) { 21 $userId = $profileUserId; 22 } 13 23 14 24 if ($profile) -
yoti/trunk/yoti.php
r1760739 r1787610 5 5 Plugin URI: https://wordpress.org/plugins/yoti/ 6 6 Description: Let Yoti users quickly register on your site. 7 Version: 1.1. 47 Version: 1.1.5 8 8 Author: Yoti SDK. 9 9 Author URI: https://yoti.com … … 26 26 if (!is_dir(YotiHelper::uploadDir())) 27 27 { 28 mkdir(YotiHelper::uploadDir(), 0777, true);28 mkdir(YotiHelper::uploadDir(), 0777, TRUE); 29 29 } 30 30 } … … 73 73 74 74 case 'bin-file': 75 $yc->binFile('selfie', !empty($_GET['user_id']) ? $_GET['user_id'] : null);75 $yc->binFile('selfie', !empty($_GET['user_id']) ? $_GET['user_id'] : NULL); 76 76 exit; 77 77 break; … … 85 85 function yoti_admin_menu() 86 86 { 87 wp_enqueue_style('yoti-asset-css', plugin_dir_url(__FILE__) . 'assets/styles.css', false);87 wp_enqueue_style('yoti-asset-css', plugin_dir_url(__FILE__) . 'assets/styles.css', FALSE); 88 88 add_options_page('Yoti', 'Yoti', 'manage_options', 'yoti', 'YotiAdmin::init'); 89 89 } … … 113 113 } 114 114 115 $noLink = (!empty($_POST['yoti_nolink'])) ? 1 : null;115 $noLink = (!empty($_POST['yoti_nolink'])) ? 1 : NULL; 116 116 117 117 echo '<div style="margin: 0 0 25px 0" class="message"> … … 126 126 * @param $user 127 127 */ 128 function yoti_login($user_login= null, $user=null)128 function yoti_login($user_login=NULL, $user=NULL) 129 129 { 130 130 if (!$user) { … … 163 163 $yotiId = get_user_meta($user->ID, 'yoti_user.identifier'); 164 164 $dbProfile = YotiHelper::getUserProfile($user->ID); 165 166 $profile = null; 165 $profileUserId = $user->ID; 166 167 $profile = NULL; 167 168 if ($yotiId && $dbProfile) 168 169 { … … 171 172 172 173 // Add profile scope 173 $show = function () use ($profile, $dbProfile ) {174 $show = function () use ($profile, $dbProfile, $profileUserId) { 174 175 require_once __DIR__ . '/views/profile.php'; 175 176 }; … … 184 185 function yoti_enqueue_scripts() 185 186 { 186 wp_enqueue_script('yoti-asset-js', 'https://sdk.yoti.com/clients/browser.js', array(), null);187 wp_enqueue_script('yoti-asset-js', YotiHelper::YOTI_SDK_JAVASCRIPT_LIBRARY, [], NULL); 187 188 } 188 189
Note: See TracChangeset
for help on using the changeset viewer.