Plugin Directory

Changeset 1787610


Ignore:
Timestamp:
12/15/2017 12:54:20 PM (8 years ago)
Author:
yotiwordpress
Message:

Integrate the new inline QR style for Yoti button

Location:
yoti/trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • yoti/trunk/README.md

    r1760739 r1787610  
    1 # Yoti Wordpress SDK #
     1# Yoti WordPress Plugin
    22
    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 ![alt text](/login_flow.png "Login flow")
    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
     3This 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).
    604
    615## Requirements
    626
    63 This SDK works with the WordPress business plan package.
     7This SDK works with the WordPress Business Plan package.
    648
    659## Installing the SDK
     10
    6611You can install the Yoti SDK in two ways:
    6712
    68 ### By importing the Yoti SDK inside your project:
     13### By importing the Yoti SDK inside your project
    6914
    70 1) Log on to the admin console of your Wordpress website. e.g. Https://www.wordpressurl.org.uk/wp-admin
    71 2) Navigate to at `Plugins > Add New`.
    72 3) Search for Yoti and install and activate the plug in.
     151. Log on to your Wordpress Admin Dashboard e.g. https://www.wordpressurl.org.uk/wp-admin
     162. Navigate to `Plugins > Add New`
     173. Search for Yoti, install and activate the plugin
    7318
    74 ### By using this repos (For Mac & Linux users)
     19### By using this repository (For MacOS and Linux users)
    7520
    76 1) Download and unzip this repository, or, clone this repository
    77 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 WordPress at `Plugins > Add New`, then click `Upload Plugin`.
    80 5) Once installed, click `Activate Plugin`.
     211. Clone this repository
     222. Run `./pack-plugin.sh`. This will download the Yoti PHP SDK and place it in the plugin directory
     233. On completion of step 2, you will have a file called `yoti-wordpress-edge.zip`.
     244. Upload this file in your Wordpress Admin Dashboard at `Plugins > Add New`, then click `Upload Plugin`.
     255. Once installed, click on `Activate Plugin`.
    8126
    8227## Plugin Setup
    8328
    8429To 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
     30You will be asked to add the following information:
    9031
    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.
    9237
    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.
     38Please do not open the .pem file as this might corrupt the key and you will need to create a new application.
    11039
    11140## Setting up your Yoti Application
    11241
    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 plugins functionality.
     42Specify 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.
    11443
    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.
     44The `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.
    11645
    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.
     46The `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.
    11847
    11948## 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.
    12649
    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.
    12851
    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
     56We provide a WordPress Docker container that includes the Yoti plugin.
     57
     58### Setup
     59
     60To try out our Docker container, clone this repository and run the following commands:
     61
     62Go to the directory where the repo was cloned:
     63
     64```shell
     65cd yoti-wordpress
     66```
     67
     68Rebuild the images if you have modified the `docker-compose.yml` file:
     69
     70```shell
     71docker-compose build --no-cache
     72```
     73
     74Build the containers:
     75
     76```shell
     77docker-compose up -d
     78```
     79
     80After the command has finished running, go to [http://localhost:7000](http://localhost:7000) and follow the instructions.
     81
     82The Yoti plugin will be installed alongside WordPress. Activate it and follow our [plugin setup process](#plugin-setup).
     83
     84### Removing the Docker containers
     85
     86Run the following commands to remove docker containers:
     87
     88```shell
     89docker-compose stop
     90docker-compose rm
     91```
    14192
    14293## Support
     
    14596Please provide the following the get you up and working as quick as possible:
    14697
    147 - Computer Type
    148 - OS Version
    149 - Screenshot
    150 
    151 
     98* Computer Type
     99* OS Version
     100* Screenshot
  • yoti/trunk/YotiAdmin.php

    r1760739 r1787610  
    5454
    5555        // Check curl has preliminary extensions to run
    56         $errors = array();
     56        $errors = [];
    5757        if (!function_exists('curl_version'))
    5858        {
     
    149149     * @return null
    150150     */
    151     protected function postVar($var, $default = null)
     151    protected function postVar($var, $default = NULL)
    152152    {
    153153        return array_key_exists($var, $_POST) ? $_POST[$var] : $default;
     
    156156    /**
    157157     * @param $var
    158      * @param null $default
    159      * @return null
     158     * @param NULL $default
     159     * @return NULL
    160160     */
    161     protected function filesVar($var, $default = null)
     161    protected function filesVar($var, $default = NULL)
    162162    {
    163163        return (array_key_exists($var, $_FILES) && !empty($_FILES[$var]['name'])) ? $_FILES[$var] : $default;
  • yoti/trunk/YotiHelper.php

    r1760739 r1787610  
    1717     */
    1818    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';
    1924
    2025    /**
  • yoti/trunk/YotiWidget.php

    r1760739 r1787610  
    33class YotiWidget extends WP_Widget
    44{
     5    const YOTI_WIDGET_DEFAULT_TITLE = 'Authenticate with Yoti';
     6
    57    /**
    68     * Register widget with WordPress.
     
    810    public function __construct()
    911    {
     12        $widget_options = ['classname' => 'yoti_widget', 'description' => __('Yoti button')];
    1013        parent::__construct(
    11             'yoti_widget', // Base ID
     14            'yoti-widget', // Base ID
    1215            esc_html__('Yoti Widget'), // Name
    13             ['description' => 'Yoti button']
     16            $widget_options
    1417        );
    1518    }
     
    2528    public function widget($args, $instance)
    2629    {
     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
    2737        wp_enqueue_style('yoti-asset-css', plugin_dir_url(__FILE__) . 'assets/styles.css');
    2838        $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        }
    2945        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);
    3147        }
    32         else {
    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'];
    3551    }
    3652
     
    4460    public function form($instance)
    4561    {
    46         $title = !empty($instance['title']) ? $instance['title'] : esc_html__('New title', 'text_domain');
     62        $title     = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
    4763        ?>
    4864      <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; ?>">
    5167        </p>
    5268        <?php
     
    6682    {
    6783        $instance = [];
    68         $instance['title'] = (!empty($new_instance['title'])) ? strip_tags($new_instance['title']) : '';
     84        $instance['title'] = sanitize_text_field($new_instance['title']);
    6985
    7086        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;
    45}
    56
     7/* ------------ Yoti Button -------------------- */
    68.yoti-connect .yoti-connect-button {
    79    text-align: center;
    810    display: inline-block;
    911    padding: 5px 10px;
    10     border: 1px solid #ccc;
    1112    background: #0085ba;
    1213    border-radius: 3px;
  • yoti/trunk/readme.txt

    r1765116 r1787610  
    44Tags: identity, verification, login, form, 2 factor, 2 step authentication, 2FA, access, privacy, authentication, security, sign in, two factor
    55Requires at least: 3.0.1
    6 Tested up to: 4.8.1
    7 Stable tag: 1.1.4
     6Tested up to: 4.9.1
     7Stable tag: 1.1.5
    88License: GNU v3
    99License URI: https://www.gnu.org/licenses/gpl.txt
     
    8888    Version     Date            Changes
    8989
     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
    9094    1.1.4       2017/08/11      Integrate SDK identifier to track plugin usage.
    9195                                Apply Yoti style to the unlink button.
  • yoti/trunk/sdk/Yoti/YotiClient.php

    r1760739 r1787610  
    2727    const DASHBOARD_URL = 'https://www.yoti.com/dashboard';
    2828
    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 = [
    3135        'PHP',
    3236        'WordPress',
     
    435439    private function isValidSdkIdentifier($providedHeader)
    436440    {
    437         if(in_array($providedHeader, self::YOTI_ACCEPTED_SDK_IDENTIFIERS, TRUE)) {
     441        if(in_array($providedHeader, $this->acceptedSDKIdentifiers, TRUE)) {
    438442            return TRUE;
    439443        }
  • yoti/trunk/views/admin-options.php

    r1760739 r1787610  
    55 * @var array $errors
    66 */
     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"' : '';
    711?>
    812<div class="wrap">
     
    7983            <th scope="row"></th>
    8084            <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>
    8286            </td>
    8387          </tr>
     
    8589            <th scope="row"></th>
    8690            <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>
    8892            </td>
    8993          </tr>
  • yoti/trunk/views/profile.php

    r1760739 r1787610  
    1111$isAdmin = in_array('administrator', $currentUser->roles, TRUE);
    1212$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
     16if(
     17    $isAdmin
     18    && $profileUserId === $currentUser->ID
     19    && is_null($userId)
     20) {
     21    $userId = $profileUserId;
     22}
    1323
    1424if ($profile)
  • yoti/trunk/yoti.php

    r1760739 r1787610  
    55Plugin URI: https://wordpress.org/plugins/yoti/
    66Description: Let Yoti users quickly register on your site.
    7 Version: 1.1.4
     7Version: 1.1.5
    88Author: Yoti SDK.
    99Author URI: https://yoti.com
     
    2626    if (!is_dir(YotiHelper::uploadDir()))
    2727    {
    28         mkdir(YotiHelper::uploadDir(), 0777, true);
     28        mkdir(YotiHelper::uploadDir(), 0777, TRUE);
    2929    }
    3030}
     
    7373
    7474            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);
    7676                exit;
    7777                break;
     
    8585function yoti_admin_menu()
    8686{
    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);
    8888    add_options_page('Yoti', 'Yoti', 'manage_options', 'yoti', 'YotiAdmin::init');
    8989}
     
    113113    }
    114114
    115     $noLink = (!empty($_POST['yoti_nolink'])) ? 1 : null;
     115    $noLink = (!empty($_POST['yoti_nolink'])) ? 1 : NULL;
    116116
    117117    echo '<div style="margin: 0 0 25px 0" class="message">
     
    126126 * @param $user
    127127 */
    128 function yoti_login($user_login=null, $user=null)
     128function yoti_login($user_login=NULL, $user=NULL)
    129129{
    130130    if (!$user) {
     
    163163    $yotiId = get_user_meta($user->ID, 'yoti_user.identifier');
    164164    $dbProfile = YotiHelper::getUserProfile($user->ID);
    165 
    166     $profile = null;
     165    $profileUserId = $user->ID;
     166
     167    $profile = NULL;
    167168    if ($yotiId && $dbProfile)
    168169    {
     
    171172
    172173    // Add profile scope
    173     $show = function () use ($profile, $dbProfile) {
     174    $show = function () use ($profile, $dbProfile, $profileUserId) {
    174175        require_once __DIR__ . '/views/profile.php';
    175176    };
     
    184185function yoti_enqueue_scripts()
    185186{
    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);
    187188}
    188189
Note: See TracChangeset for help on using the changeset viewer.