Plugin Directory

Changeset 1932034


Ignore:
Timestamp:
08/28/2018 08:58:15 PM (7 years ago)
Author:
shfarr
Message:

moving to version 1.6

Location:
identity-plus/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • identity-plus/trunk/identity-plus.php

    r1920096 r1932034  
    55   Plugin URI: https://wordpress.org/plugins/identity-plus
    66   Description: Connect your WordPress with Identity + and enable invisible 2 factor authentication, secured SSO, SSL Client Certificate based access on select pages and join the Identity + network of trust where devices and people are anonymousely rated based on how they behave.
    7    Version: 1.5
     7   Version: 1.6
    88   Author: Identity +
    99   Author URI: http://identity.plus
  • identity-plus/trunk/lib/identity_plus/Identity_Plus_API.php

    r1788347 r1932034  
    1717use identity_plus\api\communication\Reference_Number;
    1818use identity_plus\api\communication\Intrusion_Reference;
     19use identity_plus\api\communication\Intent_Type;
     20use identity_plus\api\communication\Intent;
     21use identity_plus\api\communication\Intent_Reference;
    1922
    2023/*
     
    146149     * should only be made in the presence of an ongoing session.
    147150     *
    148      * @param unknown $anonymous_id: the anonymous id extracted from the SSL Client Certificate of the visitor currently holding the session
     151     * @param unknown $serial_number: the anonymous id extracted from the SSL Client Certificate of the visitor currently holding the session
    149152     * @param unknown $local_id: the local unique id to bind with this anonymous user, the id must point back to the currently logged in user
    150153     * @param unknown $account_age_days: the number of days since this person has a local account
     
    152155     * @return if all goes well an updated Identity_Profile (with the freshly bound local user) otherwise a Simple_Response containing an error code
    153156     */
    154     public function bind_local_user($anonymous_id, $local_id, $account_age_days, $trust_so_far = 100){
    155         $request = new Local_User_Information($anonymous_id, $local_id, $account_age_days, $trust_so_far);
     157    public function bind_local_user($serial_number, $local_id, $account_age_days, $trust_so_far = 100){
     158        $request = new Local_User_Information($serial_number, $local_id, $account_age_days, $trust_so_far);
    156159        return $this->issue_call($request, "PUT");
    157160    }
     
    185188     * Adjust your trust regime based on these values.
    186189     *
    187      * @param unknown $local_user_id: the local id of the user, if applicable, if trust is added for a strange visitor this can be left empty
    188      * @param unknown $anonymous_id: this is only needed if there is no local user, in that case the trust goes to the stranger bearing this anonymous id
     190     * @param unknown $local_user_name: the local id of the user, if applicable, if trust is added for a strange visitor this can be left empty
     191     * @param unknown $serial_number: this is only needed if there is no local user, in that case the trust goes to the stranger bearing this anonymous id
    189192     * @param unknown $trust_tokens: the amount of trust.
    190193     * @return if all goes well an updated Identity_Profile (containting the extra trust) otherwise a Simple_Response containing an error code
    191194     */
    192     public function put_trust($local_user_id, $anonymous_id, $trust_tokens){
    193         $request = new Trust($local_user_id, $anonymous_id, $trust_tokens);
     195    public function put_trust($local_user_name, $serial_number, $trust_tokens){
     196        $request = new Trust($local_user_name, $serial_number, $trust_tokens);
    194197        return $this->issue_call($request, "PUT");
    195198    }
     
    205208     * If it is legitimate adjust severity accordingly.
    206209     *
    207      * @param unknown $anonymous_id: the certificate to report against.
     210     * @param unknown $serial_number: the certificate to report against.
    208211     * @param unknown $severity: the severity of the intrusion see Intrusion_Severity class
    209212     * @param unknown $message: a message to send the owner
     
    212215     * @return A reference Number for the intrusion
    213216     */
    214     public function report_intrustion($anonymous_id, $severity, $message, $url, $additional_information = ''){
     217    public function report_intrustion($serial_number, $severity, $message, $url, $additional_information = ''){
    215218        $headers = array();
    216219        foreach ($_SERVER as $key => $value){
     
    221224       
    222225        $request = new Intrusion_Report(
    223                 $anonymous_id, $severity, $message,
     226                $serial_number, $severity, $message,
    224227                $_SERVER['REMOTE_ADDR'],
    225228                $url,
     
    235238     * certificate since then.
    236239     *   
    237      * @param unknown $anonymous_id
     240     * @param unknown $serial_number
    238241     * @return if all goes well an Identity_Profile, otherwise a Simple_Response containing an error code
    239242     */
    240     public function query_identity_plus_profile($anonymous_id){
    241         $request = new Identity_Inquiry($anonymous_id);
     243    public function query_identity_plus_profile($serial_number){
     244        $request = new Identity_Inquiry($serial_number);
    242245        return $this->issue_call($request, "POST");
     246    }
     247
     248    /**
     249     * Creates an activity intent that can later be references
     250     *   
     251     * @param unknown $serial_number
     252     * @return if all goes well an Identity_Profile, otherwise a Simple_Response containing an error code
     253     */
     254    public function create_intent($type, $local_user_name, $name, $email_address, $phone_number, $return_url){
     255        $request = new Intent($type, $local_user_name, $name, $email_address, $phone_number, $return_url);
     256        return $this->issue_call($request, "PUT");
    243257    }
    244258   
     
    323337        else if(property_exists($data, 'Reference-Number')) return new Reference_Number($data->{'Reference-Number'});
    324338        else if(property_exists($data, 'Anonymous-ID')) return new Anonymous_ID($data->{'Anonymous-ID'});
     339        else if(property_exists($data, 'Intent-Reference')) return new Intent_Reference($data->{'Intent-Reference'});
    325340        else return new Simple_Response($data->{'Simple-Response'});
    326341    }
     
    356371        $payload =  Identity_Plus_Utils::base64url_decode($_GET['idp-api-response']);
    357372        $response = $this->decrypt($payload);
    358         $anonymous_id = Identity_Plus_API::decode(json_decode($response));
    359         if($anonymous_id instanceof Anonymous_ID){
    360             $http_session['identity-plus-anonymous-id'] = $anonymous_id->anonymous_id;
     373
     374        $serial_number = Identity_Plus_API::decode(json_decode($response));
     375        if($serial_number instanceof Anonymous_ID){
     376            $http_session['identity-plus-anonymous-id'] = $serial_number->serial_number;
    361377        }
    362378        else $http_session['identity-plus-anonymous-id'] = 'N/A';
  • identity-plus/trunk/lib/identity_plus/api/Communication.php

    r1535864 r1932034  
    141141
    142142/**
    143  * The Anonymous_ID is part of the Legacy HTTP call assembly.
     143 * The serial_number is part of the Legacy HTTP call assembly.
    144144 * This response comes URL encoded as part of the redirect when the the
    145145 * identity + service is used to read the client certificate from the user browser.
     
    156156     * The anonymous id as identified by the identity+ api
    157157     */
    158     public $anonymous_id;
     158    public $serial_number;
    159159
    160160    /**
     
    176176        parent::__construct($data);
    177177       
    178         $this->anonymous_id = $data->{'anonymous-id'};
     178        $this->serial_number = $data->{'serial-number'};
    179179        $this->salt = $data->{'salt'};
    180180    }
     
    231231     * this field will be empty.
    232232     */
    233     public $local_user_id;
     233    public $local_user_name;
    234234
    235235    /**
     
    287287        parent::__construct($data);
    288288
    289         if(isset($data->{'local-user-id'})) $this->local_user_id = $data->{'local-user-id'};
     289        if(isset($data->{'local-user-id'})) $this->local_user_name = $data->{'local-user-name'};
    290290        if(isset($data->{'user-secret'})) $this->user_secret = $data->{'user-secret'};
    291291        $this->trust_sponsors = $data->{'trust-sponsors'};
     
    299299}
    300300
     301/**
     302 * The response for an intent ia a reference token which comes encoded as a JSon object
     303 * so it can be easily differentiated from an error response
     304 *
     305 * @author Stefan Harsan Farr
     306 */
     307class Intent_Reference extends API_Response{
     308    /**
     309     * The reference value
     310     */
     311    public $value;
     312
     313    public function __construct($data){
     314        parent::__construct($data);
     315        $this->value = $data->{'value'};
     316    }
     317}
     318
     319/**
     320 * The type of the intent
     321 *
     322 * @author Stefan Harsan Farr
     323 */
     324class Intent_Type {
     325    /* check if the device has a certificate. This is usually necessary if the site cannot read the certificate itself. No action will be performed if certificate is not found */
     326    const discover = 'discover';
     327
     328    /* request this device to be certified. Connect device or sign up for identity plus if necessary. The operation will be performed under the brand of the domain */
     329    const request = 'request';
     330
     331    /* request this device to be certified and bind local user to it. Connect device or sign up for identity plus if necessary. The operation will be performed under the brand of the domain */
     332    const bind = 'bind';
     333}
     334
     335class Intent extends API_Request{
     336    /**
     337     * The type of the intent, can be any of {'discover', 'request', 'bind'}, see Inttent_Type
     338     */
     339    public $type;
     340
     341    /**
     342     * Local user name for the identity plus account to be bound with.
     343     * If they type is 'bind', this field must be specified
     344     */
     345    public $local_user_name;
     346
     347    /**
     348     * the URL to return to after the operation
     349     */
     350    public $return_url;
     351
     352    /**
     353     * Optionally share personal information with IdentityPlus, to speed up sign up procedure
     354     */
     355    public $name;
     356    public $email_address;
     357    public $phone_number;
     358
     359    public function __construct($type, $serial_number, $local_user_name, $name, $email_address, $phone_number, $return_url) {
     360        $this->type = $type;
     361        $this->local_user_name = $local_user_name;
     362        $this->return_url = $return_url;
     363        $this->email_address = $email_address;
     364        $this->phone_number = $phone_number;
     365        $this->name = $name;
     366    }
     367}
    301368
    302369class Identity_Inquiry extends API_Request{
    303370    /**
    304      * The anonymous id extracted from the identity + certificate of the visitor
    305      */
    306     public $anonymous_id;
    307 
    308     public function __construct($anonymous_id) {
    309         $this->anonymous_id = $anonymous_id;
     371     * The serial number extracted from the identity + certificate of the visitor
     372     */
     373    public $serial_number;
     374
     375    public function __construct($serial_number) {
     376        $this->serial_number = $serial_number;
    310377    }
    311378}
     
    346413     * at this stage identity + is not yet aware of the association, therefore it cannot search for the user name
    347414     */
    348     public $anonymous_id;
     415    public $serial_number;
    349416
    350417    /**
     
    369436    public $tokens_of_trust;
    370437
    371     public function __construct($anonymous_id, $local_user_name, $local_user_age, $tokes_of_trust = 100) {
     438    public function __construct($serial_number, $local_user_name, $local_user_age, $tokes_of_trust = 100) {
    372439        $this->local_user_name = $local_user_name;
    373440        $this->tokens_of_trust = $tokes_of_trust;
    374         $this->anonymous_id = $anonymous_id;
     441        $this->serial_number = $serial_number;
    375442        $this->local_user_age = $local_user_age;
    376443    }
     
    387454     * The anonymous id to refer. This is only available when the Identity + account is not bound to local user
    388455     */
    389     public $anonymous_id;
     456    public $serial_number;
    390457   
    391458    /**
     
    397464    public $tokens_of_trust;
    398465
    399     public function __construct($local_user_name, $anonymous_id, $tokens_of_trust){
     466    public function __construct($local_user_name, $serial_number, $tokens_of_trust){
    400467        $this->local_user_name = $local_user_name;
    401         $this->anonymous_id = $anonymous_id;
     468        $this->serial_number = $serial_number;
    402469        $this->tokens_of_trust = $tokens_of_trust;
    403470    }
  • identity-plus/trunk/lib/initialize.php

    r1788347 r1932034  
    1414use identity_plus\api\Identity_Plus_API;
    1515use identity_plus\api\communication\Anonymous_ID;
     16use identity_plus\api\communication\Intent_Type;
     17use identity_plus\api\communication\Intent_Reference;
    1618
    1719add_action( 'wp_enqueue_scripts', 'identity_pluss_cf_frame_style' );
    1820add_action( 'admin_enqueue_scripts', 'identity_pluss_cf_admin_frame_style' );
    1921
     22add_filter('manage_users_columns', 'idp_add_user_id_column');
     23add_action('manage_users_custom_column',  'idp_show_user_id_column_content', 10, 3);
     24
     25function idp_add_user_id_column($columns) {
     26    $columns['user_id'] = 'Id +';
     27    return $columns;
     28}
     29 
     30function idp_show_user_id_column_content($value, $column_name, $user_id) {
     31    $user = get_userdata( $user_id );
     32    if ( 'user_id' == $column_name ){
     33        $idp_bound = get_user_meta($user_id, 'identity-plus-bound', true);
     34        if($idp_bound) return $idp_bound;
     35        else return 'N/A';
     36    }
     37    return $value;
     38}
    2039
    2140function identity_plus_initialize(){
     
    3958            // attempt to start session
    4059            session_start();
    41             $identity_plus_api =null;
     60            $identity_plus_api = null;
    4261
    4362            // if returning from Identity + with information payload
     
    6079                   
    6180                // Get Identity + User Profile if we have anonymous id
    62                 if(!isset($_SESSION['identity-plus-user-profile'])) $identity_plus_api = identity_plus_obtain_user_profile($options, $identity_plus_api);
     81                if(!isset($_SESSION['identity-plus-user-profile'])){
     82                     $identity_plus_api = identity_plus_obtain_user_profile($options, $identity_plus_api);
     83                }
    6384            }
    6485   
     
    6687            // If Identity + Profile Exists
    6788            if(isset($_SESSION['identity-plus-user-profile'])) $identity_plus_api = identity_plus_autologin($options, $identity_plus_api);
    68    
     89
     90            // see if we triggered a bind event
     91            if(isset($_SESSION['identity-plus-user-profile']) && $_GET['bind'] && !get_user_meta($user_id, 'identity-plus-bound', true)){
     92                $user_id = get_current_user_id();
     93               
     94                // the user was already bound, we specified that via the intent, but we need to this return value so that we can
     95                // remember this connection locally (it is optional, but useful), and to give feedback to the user
     96                add_user_meta($user_id, 'identity-plus-bound', $_SESSION['identity-plus-user-profile']->local_user_name);
     97
     98                $error = "I: Your wordpress account and your identity plus account have been connected!";
     99                set_transient("identity_plus_acc_{$user_id}", $error, 45);     
     100            }   
    69101   
    70102            // verify if the resource matches the filter
     
    164196           
    165197        // If user is logged in and the Identity + profile is not bound
    166         // and if we have bind all enabled or the user is an administrator
    167         if(is_user_logged_in() && !isset($profile->local_user_id) && (isset($options['bind_all']) && $options['bind_all'] || current_user_can('administrator'))){
     198        if(is_user_logged_in() && !isset($profile->local_user_name) && false){
    168199            if($identity_plus_api == null) $identity_plus_api = identity_plus_create_api($options);
    169200   
     
    178209        // Identity + Profile with local user ID connected
    179210        // will log in the user automatically
    180         if(!is_user_logged_in() && isset($profile->local_user_id)){
    181             $user = get_user_by('id', $profile->local_user_id);
    182    
     211        if(!is_user_logged_in() && isset($profile->local_user_name)){
     212            $user = get_user_by('id', $profile->local_user_name);
     213
    183214            // Automatically log in the user who owns the certificate
    184215            if(!is_wp_error($user)){
     
    194225        // but just in case so that we know which other users are connected, when they are
    195226        // not necessarily on-line
    196         if(is_user_logged_in() && isset($profile->local_user_id)) add_user_meta(wp_get_current_user()->ID, "identity-plus-bound", $profile->local_user_id, true);
     227        if(is_user_logged_in() && isset($profile->local_user_name)) add_user_meta(wp_get_current_user()->ID, "identity-plus-bound", $profile->local_user_name, true);
    197228}
    198229
     
    222253        // This one is more restrictive
    223254        $lock_resource = false;
    224         if(isset($options['lock-down']) && $options['lock-down'] && (!isset($_SESSION['identity-plus-user-profile']) || !isset($_SESSION['identity-plus-user-profile']->local_user_id))){
     255
     256        // unifying lock-down and enforce to avoid confusion so we are taking this sectionout
     257        // if(isset($options['lock-down']) && $options['lock-down'] && (!isset($_SESSION['identity-plus-user-profile']) || !isset($_SESSION['identity-plus-user-profile']->local_user_name))){
    225258            // If lock down is on and
    226259            // No Identity + Profile or there is no local user bound
    227             $lock_resource = true;
    228         }
    229         else if(isset($options['enforce']) && $options['enforce']  && !isset($_SESSION['identity-plus-user-profile'])){
     260        //  $lock_resource = true;
     261        //} else
     262
     263        if(isset($options['enforce']) && $options['enforce']  && !isset($_SESSION['identity-plus-user-profile'])){
    230264            // Enforce is on and
    231265            // No Identity + Profile
     
    263297               
    264298                // add the footer cross-validation widget
    265                 if(isset($identity_plus_api) && $identity_plus_api != NULL){?>
     299                if(false && isset($identity_plus_api) && $identity_plus_api != NULL){?>
    266300                        <iframe src="<?php echo Identity_Plus_API::validation_endpoint; ?>/widgets/cross-validation?origin=<?php echo $identity_plus_api->cert_details['serialNumber'] ?>&challenge=<?php echo  $identity_plus_api->compute_challenge()?>" scrolling="no" class="identity-plus-cf"></iframe>
    267301                        <?php
  • identity-plus/trunk/lib/settings_panel.php

    r1788347 r1932034  
    66}
    77
     8use identity_plus\api\communication\Intent_Type;
     9
     10
    811add_action( 'admin_enqueue_scripts', 'identity_plus_admin_styles' );
    912add_action( 'admin_menu', 'identity_plus_add_admin_menu' );
     
    1316
    1417function identity_plus_add_admin_menu(  ) {
    15         add_options_page( 'Identity +', 'Identity +', 'manage_options', 'identity_plus_network_of_trust', 'identity_plus_options_page' );
     18        add_options_page( 'IdentityPlus Settings', 'Identity +', 'manage_options', 'identity_plus_network_of_trust', 'identity_plus_options_page' );
    1619}
    1720
     
    3639        add_settings_field('cert-file', __( 'Certificate File', 'identity_plus' ),  'identity_plus_cert_file_render', 'identity_plus_cert_section', 'identity_plus_identity_plus_cert_section_section');
    3740        add_settings_field('cert-password', __( 'Certificate Password', 'identity_plus' ), 'identity_plus_cert_password_render', 'identity_plus_cert_section',  'identity_plus_identity_plus_cert_section_section' );
    38    
    39         add_settings_section('identity_plus_behavior_section',  __( 'Behavior', 'identity_plus' ), 'identity_plus_behavior_section_callback', 'identity_plus_cert_section');
    40         add_settings_field('bind_all', __( 'Connect Any User', 'identity_plus' ), 'identity_plus_bind_all_render', 'identity_plus_cert_section', 'identity_plus_behavior_section');
    41        
     41           
    4242        add_settings_section('identity_plus_access_section',    __( 'Resource Access', 'identity_plus' ), 'identity_plus_settings_section_callback', 'identity_plus_cert_section');
    4343        add_settings_field('enforce', __( 'Filtered Page Access', 'identity_plus' ), 'identity_plus_enforce_render', 'identity_plus_cert_section', 'identity_plus_access_section');
    44         add_settings_field('lock-down', __( 'Lock Down Filtered Pages', 'identity_plus' ), 'identity_plus_lock_down_render', 'identity_plus_cert_section', 'identity_plus_access_section');
     44#       add_settings_field('lock-down', __( 'Lock Down Filtered Pages', 'identity_plus' ), 'identity_plus_lock_down_render', 'identity_plus_cert_section', 'identity_plus_access_section');
    4545        add_settings_field('page-filter', __( 'Page Filter', 'identity_plus' ), 'identity_plus_page_filter_render', 'identity_plus_cert_section',   'identity_plus_access_section');
    4646   
     
    6565
    6666
    67 function identity_plus_bind_all_render(  ) {
    68         $options = get_option( 'identity_plus_settings' );?>
    69         <input type='checkbox' id='identity_plus_settings[bind_all]' name='identity_plus_settings[bind_all]' <?php isset($options['bind_all']) ? checked( $options['bind_all'], 1 ) : ""; ?> value='1'><label for='identity_plus_settings[bind_all]'>Enabled</label>
    70         <p style="max-width:640px; font-size:90%; color:rgba(0, 0, 0, 0.6);">The default behavior is to only bind administrator accounts, but if this option is checked, the plug-in will bind all local user to their Identity + accounts.
    71         Caution must be taken with this option if you have the free, Personal API Ccertificate, as it only allows for 10 users to be bound</p><?php
    72 }
    73 
    74 
    7567
    7668function identity_plus_comments_render(  ) {
    7769        $options = get_option( 'identity_plus_settings' );?>
    7870        <input type='checkbox' id='identity_plus_settings[comments]' name='identity_plus_settings[comments]' <?php isset($options['comments']) ? checked( $options['comments'], 1 ) : ""; ?> value='1'><label for='identity_plus_settings[comments]'>Enforce Identity + SSL Client Certificate</label>
    79         <p style="max-width:640px; font-size:90%; color:rgba(0, 0, 0, 0.6);">When Identity + SSL Client Certificate is enforced, comments will be blocked to devices with no certificates.
     71        <p class="identity-plus-hint" style="max-width:640px; font-size:90%; color:rgba(0, 0, 0, 0.6);">When Identity + SSL Client Certificate is enforced, comments will be blocked to devices with no certificates.
    8072        Devices that have certificate and submit spam, will be blocked upon the first report of the smap preventing them from repeating the action.
    8173        This makes the life of spammers extremely difficul.</p><?php
     
    8779        $options = get_option( 'identity_plus_settings' );?>
    8880        <input type='checkbox' id='identity_plus_settings[enforce]' name='identity_plus_settings[enforce]' <?php isset($options['enforce']) ? checked( $options['enforce'], 1 ) : ""; ?> value='1'><label for='identity_plus_settings[enforce]'>Enforce Identity + Device Certificate</label>
    89         <p style="max-width:640px; font-size:90%; color:rgba(0, 0, 0, 0.6);">When Identity + certificate is enforced, resources starting with any of the enumerated filters will only
     81        <p class="identity-plus-hint" style="max-width:640px; font-size:90%; color:rgba(0, 0, 0, 0.6);">When Identity + certificate is enforced, resources starting with any of the enumerated filters will only
    9082        be accessible from devices (desktop / laptop /mobile ) bearing a valid Identity + SSL Client Certificate. Local user roles apply</p><?php
    9183}
     
    9688        $options = get_option( 'identity_plus_settings' );?>
    9789        <input type='checkbox' id='identity_plus_settings[lock-down]' name='identity_plus_settings[lock-down]' <?php isset($options['lock-down']) ? checked( $options['lock-down'], 1 ) : ""; ?> value='1'><label for='identity_plus_settings[lock-down]'>Enabled</label>
    98         <p style="max-width:640px; font-size:90%; color:rgba(0, 0, 0, 0.6);">When lock down is enabled the filtered resources will only be accessible to Identity + connected users.</p><?php
     90        <p class="identity-plus-hint" style="max-width:640px; font-size:90%; color:rgba(0, 0, 0, 0.6);">When lock down is enabled the filtered resources will only be accessible to Identity + connected users.</p><?php
    9991}
    10092
     
    10395function identity_plus_page_filter_render(  ) {
    10496        $options = get_option( 'identity_plus_settings' );?>
     97        <label for='identity_plus_settings[page-filter]'>One filter per line.</label>
    10598        <textarea cols='40' rows='5' name='identity_plus_settings[page-filter]'><?php echo isset($options['page-filter']) && strlen($options['page-filter']) > 0 ? $options['page-filter'] : "/wp-admin\n/wp-login.php"; ?></textarea>
    106         <label for='identity_plus_settings[page-filter]'>
    107                 <br>One filter per line.<br>
    108         </label>
    10999        <?php
    110100}
     
    154144
    155145
    156 function identity_plus_behavior_section_callback(  ) {
    157         ?><p class="identity-plus-separator" style="padding-top:5px;"></p><p class="identity-plus-hint">Users that are connected can automatically be logged in.</p>
    158         <?php
    159                 // display at most 30 already bound users
    160                 $users = get_users(array('meta_key' => 'identity-plus-bound'));
    161                 $user_count = sizeof($users);
    162                 $display = 0;
    163                 $text = "";
    164                
    165                 foreach ($users as $u){
    166                         if(strlen($text) > 0){
    167                                 $text .= ", ";
    168                                 if($display % 10 == 0) $text .= "<br>";
    169                         }
    170                         $text .= $u->user_login.($u->user_login == wp_get_current_user()->user_login ? ' <sup style="color:#808080;" >(you)</sup>' : "")." {".$u->ID."}";
    171                            
    172                         if($display == 29) break;
    173                         else $display++;
    174                 }
    175 
    176                 if($user_count > $display) $text .= "<br>and other ".($user_count - $display -31)." user(s)";
    177         ?>
    178         <div class="cert"><h4>Users Connected</h4><p><?php echo $text; ?></p></div><?php
    179 }
    180 
    181 
    182 
    183146function identity_plus_admin_styles(  ) {
    184147        ?>
    185148        <style>
    186                 .identity-plus-main-fm {margin:0; background:url('<?php echo plugins_url( 'img/identity-plus-shield.svg', __FILE__ ) ?>') no-repeat top left; background-size:96px;}
     149                .identity-plus-main-fm {margin:0; background:url('<?php echo plugins_url( 'img/idp.svg', __FILE__ ) ?>') no-repeat top left; background-size:64px;}
    187150                .identity-plus-main-fm th{padding-bottom:15px; padding-top:15px; color:#136a92;}
    188151                .identity-plus-main-fm td{padding-bottom:10px; padding-top:10px; }
    189                 .identity-plus-main-fm h1{padding-left:95px; padding-top:20px; margin-bottom:0; font-size:36px;font-weight:normal; }
    190                 .identity-plus-main-fm h5{padding-left:95px; font-size:20px; font-weight:300; padding-top:0; margin-top:15px;}
    191                 .identity-plus-main-fm h2, .identity-plus-main-fm h3{border-bottom:0; background:#202020; float:left; padding:5px 20px; margin-bottom:0px; color:#D0D0D0; font-weight:normal; border-top-left-radius:5px; border-top-right-radius:5px; margin-left:10px;}
     152                .identity-plus-main-fm h1{padding-left:80px; padding-top:10px; margin-bottom:0; font-size:36px;font-weight:normal; }
     153                .identity-plus-main-fm h5{padding-left:80px; font-size:20px; font-weight:300; padding-bottom:5px; padding-top:0; margin-top:15px;}
     154                .identity-plus-main-fm h2, .identity-plus-main-fm h3{border-bottom:0; background:#303030; float:left; clear:left; padding:5px 20px; margin-bottom:0px; color:#62B2F3; font-weight:normal; border-top-left-radius:5px; border-top-right-radius:5px; margin-left:10px;}
    192155                .identity-plus-main-fm h4{border-bottom:1px solid #E0E0E0; color:#707070; padding-bottom:3px; padding-top:10px; margin-bottom:5px; font-weight:normal; font-size:16px;padding-top:0; margin-top:0; }
    193156                .identity-plus-main-fm .cert {max-width:600px; border-radius:3px; float:left; clear:both;}
    194157                .identity-plus-main-fm .cert p span{font-weight:bold;}
    195                 .identity-plus-main-fm .cert p{margin:0px;}
     158                .identity-plus-main-fm .cert p{margin:0px; float:left; clear:left;}
    196159                .identity-plus-main-fm .cert {padding:10px; background:rgba(255, 255, 255, 0.6); border:1px solid rgba(0, 0, 0, 0.3);}
    197                 .identity-plus-separator{border-top:1px solid #000000; margin-top:0px; float:left; width:90%; clear:both; -webkit-box-shadow: inset 0px 3px 13px -5px rgba(0,0,0,0.75); -moz-box-shadow: inset 0px 3px 13px -5px rgba(0,0,0,0.75); box-shadow: inset 0px 3px 13px -8px rgba(0,0,0,0.75); height:5px; margin-bottom:0px;}
     160                .identity-plus-separator{border-top:1px solid #303030; margin-top:0px; float:left; width:90%; clear:both; height:5px; margin-bottom:0px;}
    198161                .identity-plus-hint{float:left; clear:both; max-width:600px; color:#606060; font-size:14px; margin-top:0px; margin-bottom:10px;}
     162                .identity-plus-brand span{color:#4292D3;}
     163                .identity-plus-main-fm input, .identity-plus-main-fm textarea{ float:left; clear:left;}
     164                .identity-plus-main-fm input[type="checkbox"]{ margin-top:0; margin-right:5px;}
     165                .identity-plus-main-fm label{ float:left; font-weight:400;}
     166                .identity-plus-main-fm div{float:left; clear:left; overflow:hidden; margin-bottom:10px;}
     167                .identity-plus-main-fm table{max-width:600px; float:left; clear:left;}
     168                .identity-plus-main-fm table th img{border-radius:60px; border:3px solid #D0D0D0;}
    199169        </style>
    200170        <?php
     
    206176        ?>
    207177        <form class="identity-plus-main-fm" action='options.php' method='post' enctype="multipart/form-data">
    208                 <h1>Identity +</h1>
    209                 <h5>of man &amp; machine</h5>
     178                <h1 class="identity-plus-brand">Identity<span>plus</span></h1>
     179                <h5>man &amp; machine</h5>
    210180                <?php
    211181                        settings_fields( 'identity_plus_cert_section' );
     
    244214
    245215
     216# -------------------------- Id + Menu Page
     217
     218add_action( 'admin_action_identity_plus_connect', 'identity_plus_connect');
     219function identity_plus_connect(){
     220        $user_id = get_current_user_id();
     221        $options = get_option( 'identity_plus_settings' );
     222        if($identity_plus_api == null) $identity_plus_api = identity_plus_create_api($options);
     223
     224        if(isset($_SESSION['identity-plus-user-profile'])){
     225            $profile = $identity_plus_api->bind_local_user($_SESSION['identity-plus-anonymous-id'], $user_id, $days);
     226
     227            $_SESSION['identity-plus-user-profile'] = $profile;
     228            add_user_meta($user_id, 'identity-plus-bound', $user_id);
     229              $error = "I: Your wordpress account and your identity plus account have been connected!";
     230            set_transient("identity_plus_acc_{$user_id}", $error, 45);     
     231
     232            wp_redirect( $_SERVER['HTTP_REFERER'] );
     233        }
     234        else{
     235            $user_info = get_userdata($user_id);
     236            $intent = $identity_plus_api->create_intent(Intent_Type::bind, $user_id, $user_info->user_firstname . ' ' . $user_info->user_lastname, $user_info->user_email, '', $_SERVER['HTTP_REFERER'] . '&bind=true');
     237            wp_redirect('https://get.identity.plus?intent=' . $intent->value);
     238        }
     239
     240        exit();
     241}
     242
     243add_action( 'admin_action_identity_plus_disconnect', 'identity_plus_disconnect');
     244function identity_plus_disconnect(){
     245        $user_id = get_current_user_id();
     246
     247        if(!$_REQUEST['idp-i-am-sure']){
     248            $error = "E: Please reinforce your desire to disconnect by checking the appropriate checkbox!";
     249            set_transient("identity_plus_acc_{$user_id}", $error, 45);     
     250        }
     251        else{
     252            $options = get_option('identity_plus_settings' );
     253            if($identity_plus_api == null) $identity_plus_api = identity_plus_create_api($options);
     254            $profile = $identity_plus_api->unbind_local_user($user_id);
     255            $_SESSION['identity-plus-user-profile'] = $profile;
     256
     257            unset($_SESSION['identity-plus-user-profile']);
     258            unset($_SESSION['identity-plus-anonymous-id']);
     259
     260            delete_user_meta($user_id, 'identity-plus-bound');
     261            $error = "I: Your wordpress account and your identity plus account have been disconnected!";
     262            set_transient("identity_plus_acc_{$user_id}", $error, 45);
     263        }
     264
     265        wp_redirect( $_SERVER['HTTP_REFERER'] );
     266        exit();
     267}
     268
     269add_action( 'admin_menu', 'identity_plus_add_idp_page' );
     270
     271function identity_plus_add_idp_page(  ) {
     272        $options = get_option( 'identity_plus_settings' );
     273        if(!empty($options) && isset($options['cert-file'])){
     274            add_menu_page(
     275                    'My IdentityPlus',
     276                    'Device Identity',
     277                    'manage_options',
     278                    'identity_plus_authentication',
     279                    'identity_plus_authentication_page',
     280                    'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyAgIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIiAgIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyIgICB4bWxuczpzdmc9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgICB4bWxuczpzb2RpcG9kaT0iaHR0cDovL3NvZGlwb2RpLnNvdXJjZWZvcmdlLm5ldC9EVEQvc29kaXBvZGktMC5kdGQiICAgeG1sbnM6aW5rc2NhcGU9Imh0dHA6Ly93d3cuaW5rc2NhcGUub3JnL25hbWVzcGFjZXMvaW5rc2NhcGUiICAgdmVyc2lvbj0iMS4xIiAgIGlkPSJMYXllcl8xIiAgIHg9IjBweCIgICB5PSIwcHgiICAgd2lkdGg9IjEyOHB4IiAgIGhlaWdodD0iMTI4cHgiICAgdmlld0JveD0iMCAwIDEyOCAxMjgiICAg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DE3LjExMzI4MSwwIHogbSAtNzkuODAwNzgxLDUuMzc2OTUzIDExLjczNjMyOCwwIDAsMzYuNzIwNzAzIC0xMS43MzYzMjgsMCB6IG0gMzYuMzI2MTcyLDcuNjM4NjcyIGMgLTIuNDkxNzc4LDAgLTQuNDAzMDA4LDAuOTE3ODU5IC01LjczNjMyOCwyLjc1MzkwNiAtMS4zMTE0NjIsMS44MzYwNDcgLTEuOTY4NzUsNC41MDI3NjcgLTEuOTY4NzUsOCAwLDMuNDk3MjMzIDAuNjU3Mjg4LDYuMTYzOTUzIDEuOTY4NzUsOCAxLjMzMzMyLDEuODM2MDQ3IDMuMjQ0NTUsMi43NTM5MDYgNS43MzYzMjgsMi43NTM5MDYgMi41MTM2MzYsMCA0LjQyNjgxOSwtMC45MTc4NTkgNS43MzgyODEsLTIuNzUzOTA2IDEuMzMzMzIsLTEuODM2MDQ3IDIsLTQuNTAyNzY3IDIsLTggMCwtMy40OTcyMzMgLTAuNjY2NjgsLTYuMTYzOTUzIC0yLC04IC0xLjMxMTQ2MiwtMS44MzYwNDcgLTMuMjI0NjQ1LC0yLjc1MzkwNiAtNS43MzgyODEsLTIuNzUzOTA2IHoiICAgICAgIGlkPSJyZWN0NSIgICAgICAgaW5rc2NhcGU6Y29ubmVjdG9yLWN1cnZhdHVyZT0iMCIgICAgICAgc29kaXBvZGk6bm9kZXR5cGVzPSJjY2NjY2NjY2NjY2NjY2NzY2NjY2NjY2NjY2NjY2NjY2NjY2Njc2NzY3Njc2NzIiAvPjwvZz48ZyAgICAgaWQ9ImcyNSIgLz48ZyAgICAgaWQ9ImcyNyIgLz48ZyAgICAgaWQ9ImcyOSIgLz48ZyAgICAgaWQ9ImczMSIgLz48ZyAgICAgaWQ9ImczMyIgLz48L3N2Zz4='
     281            );
     282        }
     283}
     284
     285function identity_plus_idp_page(  ) {
     286        $user_id = get_current_user_id();
     287        $msg = get_transient("identity_plus_acc_{$user_id}");
     288        if($msg){
     289            if(strpos($msg, 'E: ') === 0){ ?><div class="error is-dismissible"><p><?php echo substr($msg, 3); ?></p></div><?php }
     290            else{ ?><div class="notice notice-success is-dismissible"><p><?php echo substr($msg, 3); ?></p></div><?php }
     291            delete_transient("identity_plus_acc_{$user_id}");
     292        }
     293
     294        $options = get_option( 'identity_plus_settings' );
     295
     296        ?>
     297                <?php if(get_user_meta($user_id, 'identity-plus-bound', true)){ ?>
     298                    <table><tr>
     299                            <th><img width="64" height="64" src="https://my.identity.plus/widgets/profile-picture"></th>
     300                            <td><p class="identity-plus-hint">
     301                                Your Wordpress uses <a target="_blank" title="My Identity Plus Application" href="https://my.identity.plus"><span>identity</span></a> to protect your account and your credentials.
     302                                You can now enjoy secure password-less experience. Only devices owned and registered by you can access your Wordpress account.
     303                            </p></td>
     304                    </tr></table>
     305
     306                    <h2>Disconnect</h2><p class="identity-plus-separator" style="padding-top:5px;"></p>
     307                    <?php if(isset($options['enforce']) && checked( $options['enforce'], 1 )){ ?>
     308                        <p class="identity-plus-hint" >Your <a href="<?php echo admin_url('options-general.php?page=identity_plus_network_of_trust'); ?>">identityplus settings</a> only allow admin access from certified devices. Disconnect is disabled as you would lock yourself out from admin section.</p>
     309                    <?php } else { ?>
     310                        <p class="identity-plus-hint" >By disconnecting your identityplus account from the local account, you will lose the ability to sign in via device id. Are you sure?</p>
     311                        <input type="hidden" name="action" value="identity_plus_disconnect">
     312                        <div><input type="checkbox" id="idp-i-am-sure" name="idp-i-am-sure" onchange="document.getElementById('identity_plus_disconnect').style.display = document.getElementById('idp-i-am-sure').checked ? 'block' : 'none';"><label for="idp-i-am-sure">Yes, I am sure I want to disconnect.</label></div>
     313                        <input type="submit" id="identity_plus_disconnect" style="display:none; background:#900000; color:#FFFFFF; padding:7px 15px 5px 15px; border-radius:2px; border:1px solid #500000" value="DISCONNECT">
     314                    <?php } ?>
     315
     316                <?php } else if(isset($_SESSION['identity-plus-user-profile'])){ ?>
     317                    <table><tr>
     318                            <th><img width="64" height="64" src="https://my.identity.plus/widgets/profile-picture"></th>
     319                            <td>
     320                                <p class="identity-plus-hint">
     321                                    Your Wordpress uses <a target="_blank" title="My Identity Plus Application" href="https://identity.plus"><span>identity</span></a> to protect your account and your credentials by
     322                                    only allowing devices owned and registered by you to access your Wordpress account.
     323                                </p>
     324                            </td>
     325                    </tr></table>
     326                   
     327                    <p class="identity-plus-hint" >Connect your identity<span class="identity-plus-brand">plus</span> account for secure, password-less login experience.</p>
     328                    <input type="hidden" name="action" value="identity_plus_connect">
     329                    <input type="submit" id="identity_plus_disconnect" style="background:#303030; color:#62B2F3; padding:7px 15px 5px 15px; border-radius:2px; border:1px solid #000000" value="CONNECT">
     330                <?php } else { ?>
     331                    <table><tr>
     332                            <td>
     333                                <p class="identity-plus-hint">
     334                                    Your Wordpress uses <a target="_blank" title="My Identity Plus Application" href="https://identity.plus"><span>identity</span></a> to protect your account and your credentials by
     335                                    only allowing devices owned and registered by you to access your Wordpress account.
     336                                </p>
     337                            </td>
     338                    </tr></table>
     339                   
     340                    <p class="identity-plus-hint" >Get your free <span class="identity-plus-brand">plus</span> account for secure, password-less login experience.</p>
     341                    <input type="hidden" name="action" value="identity_plus_connect">
     342                    <input type="submit" id="identity_plus_disconnect" style="background:#303030; color:#62B2F3; padding:7px 15px 5px 15px; border-radius:2px; border:1px solid #000000" value="Get Id+">
     343                <?php } ?>
     344        <?php
     345}
     346
     347
     348function identity_plus_authentication_page(  ) {
     349        ?>
     350        <form class="identity-plus-main-fm" method="post" action="<?php echo admin_url( 'admin.php' ); ?>">
     351                <h1 class="identity-plus-brand">Identity<span>plus</span></h1>
     352                <h5>man &amp; machine</h5>
     353                <?php wp_nonce_field('my_delete_action'); ?>
     354                <?php identity_plus_idp_page(); ?>
     355        </form>
     356        <?php
     357}
     358
     359
    246360add_filter('upload_mimes', 'identity_plus_enable_extra_extensions');
     361
  • identity-plus/trunk/readme.txt

    r1920096 r1932034  
    8282== Changelog ==
    8383
     84== 1.6 ==
     85Migrated to v1.1 Identityplus API. Identityplus plugin now allows individual wordpress users to connect their accounts on-demand. This new version also lifted the 10 accounts limit for non-corporate certificates, meaning that not-for-profit sites (public benefit or personal sites that produce no revenue) can connect any number of accounts at no cost.
     86
    8487= 1.5 =
    8588Verified compatibility with Wordpress 4.9.8.
Note: See TracChangeset for help on using the changeset viewer.