Changeset 1932034
- Timestamp:
- 08/28/2018 08:58:15 PM (7 years ago)
- Location:
- identity-plus/trunk
- Files:
-
- 6 edited
-
identity-plus.php (modified) (1 diff)
-
lib/identity_plus/Identity_Plus_API.php (modified) (10 diffs)
-
lib/identity_plus/api/Communication.php (modified) (10 diffs)
-
lib/initialize.php (modified) (9 diffs)
-
lib/settings_panel.php (modified) (10 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
identity-plus/trunk/identity-plus.php
r1920096 r1932034 5 5 Plugin URI: https://wordpress.org/plugins/identity-plus 6 6 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. 57 Version: 1.6 8 8 Author: Identity + 9 9 Author URI: http://identity.plus -
identity-plus/trunk/lib/identity_plus/Identity_Plus_API.php
r1788347 r1932034 17 17 use identity_plus\api\communication\Reference_Number; 18 18 use identity_plus\api\communication\Intrusion_Reference; 19 use identity_plus\api\communication\Intent_Type; 20 use identity_plus\api\communication\Intent; 21 use identity_plus\api\communication\Intent_Reference; 19 22 20 23 /* … … 146 149 * should only be made in the presence of an ongoing session. 147 150 * 148 * @param unknown $ anonymous_id: the anonymous id extracted from the SSL Client Certificate of the visitor currently holding the session151 * @param unknown $serial_number: the anonymous id extracted from the SSL Client Certificate of the visitor currently holding the session 149 152 * @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 150 153 * @param unknown $account_age_days: the number of days since this person has a local account … … 152 155 * @return if all goes well an updated Identity_Profile (with the freshly bound local user) otherwise a Simple_Response containing an error code 153 156 */ 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); 156 159 return $this->issue_call($request, "PUT"); 157 160 } … … 185 188 * Adjust your trust regime based on these values. 186 189 * 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 empty188 * @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 id190 * @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 189 192 * @param unknown $trust_tokens: the amount of trust. 190 193 * @return if all goes well an updated Identity_Profile (containting the extra trust) otherwise a Simple_Response containing an error code 191 194 */ 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); 194 197 return $this->issue_call($request, "PUT"); 195 198 } … … 205 208 * If it is legitimate adjust severity accordingly. 206 209 * 207 * @param unknown $ anonymous_id: the certificate to report against.210 * @param unknown $serial_number: the certificate to report against. 208 211 * @param unknown $severity: the severity of the intrusion see Intrusion_Severity class 209 212 * @param unknown $message: a message to send the owner … … 212 215 * @return A reference Number for the intrusion 213 216 */ 214 public function report_intrustion($ anonymous_id, $severity, $message, $url, $additional_information = ''){217 public function report_intrustion($serial_number, $severity, $message, $url, $additional_information = ''){ 215 218 $headers = array(); 216 219 foreach ($_SERVER as $key => $value){ … … 221 224 222 225 $request = new Intrusion_Report( 223 $ anonymous_id, $severity, $message,226 $serial_number, $severity, $message, 224 227 $_SERVER['REMOTE_ADDR'], 225 228 $url, … … 235 238 * certificate since then. 236 239 * 237 * @param unknown $ anonymous_id240 * @param unknown $serial_number 238 241 * @return if all goes well an Identity_Profile, otherwise a Simple_Response containing an error code 239 242 */ 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); 242 245 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"); 243 257 } 244 258 … … 323 337 else if(property_exists($data, 'Reference-Number')) return new Reference_Number($data->{'Reference-Number'}); 324 338 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'}); 325 340 else return new Simple_Response($data->{'Simple-Response'}); 326 341 } … … 356 371 $payload = Identity_Plus_Utils::base64url_decode($_GET['idp-api-response']); 357 372 $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; 361 377 } 362 378 else $http_session['identity-plus-anonymous-id'] = 'N/A'; -
identity-plus/trunk/lib/identity_plus/api/Communication.php
r1535864 r1932034 141 141 142 142 /** 143 * The Anonymous_IDis part of the Legacy HTTP call assembly.143 * The serial_number is part of the Legacy HTTP call assembly. 144 144 * This response comes URL encoded as part of the redirect when the the 145 145 * identity + service is used to read the client certificate from the user browser. … … 156 156 * The anonymous id as identified by the identity+ api 157 157 */ 158 public $ anonymous_id;158 public $serial_number; 159 159 160 160 /** … … 176 176 parent::__construct($data); 177 177 178 $this-> anonymous_id = $data->{'anonymous-id'};178 $this->serial_number = $data->{'serial-number'}; 179 179 $this->salt = $data->{'salt'}; 180 180 } … … 231 231 * this field will be empty. 232 232 */ 233 public $local_user_ id;233 public $local_user_name; 234 234 235 235 /** … … 287 287 parent::__construct($data); 288 288 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'}; 290 290 if(isset($data->{'user-secret'})) $this->user_secret = $data->{'user-secret'}; 291 291 $this->trust_sponsors = $data->{'trust-sponsors'}; … … 299 299 } 300 300 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 */ 307 class 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 */ 324 class 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 335 class 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 } 301 368 302 369 class Identity_Inquiry extends API_Request{ 303 370 /** 304 * The anonymous idextracted from the identity + certificate of the visitor305 */ 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; 310 377 } 311 378 } … … 346 413 * at this stage identity + is not yet aware of the association, therefore it cannot search for the user name 347 414 */ 348 public $ anonymous_id;415 public $serial_number; 349 416 350 417 /** … … 369 436 public $tokens_of_trust; 370 437 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) { 372 439 $this->local_user_name = $local_user_name; 373 440 $this->tokens_of_trust = $tokes_of_trust; 374 $this-> anonymous_id = $anonymous_id;441 $this->serial_number = $serial_number; 375 442 $this->local_user_age = $local_user_age; 376 443 } … … 387 454 * The anonymous id to refer. This is only available when the Identity + account is not bound to local user 388 455 */ 389 public $ anonymous_id;456 public $serial_number; 390 457 391 458 /** … … 397 464 public $tokens_of_trust; 398 465 399 public function __construct($local_user_name, $ anonymous_id, $tokens_of_trust){466 public function __construct($local_user_name, $serial_number, $tokens_of_trust){ 400 467 $this->local_user_name = $local_user_name; 401 $this-> anonymous_id = $anonymous_id;468 $this->serial_number = $serial_number; 402 469 $this->tokens_of_trust = $tokens_of_trust; 403 470 } -
identity-plus/trunk/lib/initialize.php
r1788347 r1932034 14 14 use identity_plus\api\Identity_Plus_API; 15 15 use identity_plus\api\communication\Anonymous_ID; 16 use identity_plus\api\communication\Intent_Type; 17 use identity_plus\api\communication\Intent_Reference; 16 18 17 19 add_action( 'wp_enqueue_scripts', 'identity_pluss_cf_frame_style' ); 18 20 add_action( 'admin_enqueue_scripts', 'identity_pluss_cf_admin_frame_style' ); 19 21 22 add_filter('manage_users_columns', 'idp_add_user_id_column'); 23 add_action('manage_users_custom_column', 'idp_show_user_id_column_content', 10, 3); 24 25 function idp_add_user_id_column($columns) { 26 $columns['user_id'] = 'Id +'; 27 return $columns; 28 } 29 30 function 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 } 20 39 21 40 function identity_plus_initialize(){ … … 39 58 // attempt to start session 40 59 session_start(); 41 $identity_plus_api = null;60 $identity_plus_api = null; 42 61 43 62 // if returning from Identity + with information payload … … 60 79 61 80 // 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 } 63 84 } 64 85 … … 66 87 // If Identity + Profile Exists 67 88 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 } 69 101 70 102 // verify if the resource matches the filter … … 164 196 165 197 // 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){ 168 199 if($identity_plus_api == null) $identity_plus_api = identity_plus_create_api($options); 169 200 … … 178 209 // Identity + Profile with local user ID connected 179 210 // 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 183 214 // Automatically log in the user who owns the certificate 184 215 if(!is_wp_error($user)){ … … 194 225 // but just in case so that we know which other users are connected, when they are 195 226 // 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); 197 228 } 198 229 … … 222 253 // This one is more restrictive 223 254 $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))){ 225 258 // If lock down is on and 226 259 // 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'])){ 230 264 // Enforce is on and 231 265 // No Identity + Profile … … 263 297 264 298 // 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){?> 266 300 <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> 267 301 <?php -
identity-plus/trunk/lib/settings_panel.php
r1788347 r1932034 6 6 } 7 7 8 use identity_plus\api\communication\Intent_Type; 9 10 8 11 add_action( 'admin_enqueue_scripts', 'identity_plus_admin_styles' ); 9 12 add_action( 'admin_menu', 'identity_plus_add_admin_menu' ); … … 13 16 14 17 function 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' ); 16 19 } 17 20 … … 36 39 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'); 37 40 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 42 42 add_settings_section('identity_plus_access_section', __( 'Resource Access', 'identity_plus' ), 'identity_plus_settings_section_callback', 'identity_plus_cert_section'); 43 43 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'); 45 45 add_settings_field('page-filter', __( 'Page Filter', 'identity_plus' ), 'identity_plus_page_filter_render', 'identity_plus_cert_section', 'identity_plus_access_section'); 46 46 … … 65 65 66 66 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><?php72 }73 74 75 67 76 68 function identity_plus_comments_render( ) { 77 69 $options = get_option( 'identity_plus_settings' );?> 78 70 <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. 80 72 Devices that have certificate and submit spam, will be blocked upon the first report of the smap preventing them from repeating the action. 81 73 This makes the life of spammers extremely difficul.</p><?php … … 87 79 $options = get_option( 'identity_plus_settings' );?> 88 80 <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 only81 <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 90 82 be accessible from devices (desktop / laptop /mobile ) bearing a valid Identity + SSL Client Certificate. Local user roles apply</p><?php 91 83 } … … 96 88 $options = get_option( 'identity_plus_settings' );?> 97 89 <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><?php90 <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 99 91 } 100 92 … … 103 95 function identity_plus_page_filter_render( ) { 104 96 $options = get_option( 'identity_plus_settings' );?> 97 <label for='identity_plus_settings[page-filter]'>One filter per line.</label> 105 98 <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>109 99 <?php 110 100 } … … 154 144 155 145 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 <?php159 // display at most 30 already bound users160 $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><?php179 }180 181 182 183 146 function identity_plus_admin_styles( ) { 184 147 ?> 185 148 <style> 186 .identity-plus-main-fm {margin:0; background:url('<?php echo plugins_url( 'img/id entity-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;} 187 150 .identity-plus-main-fm th{padding-bottom:15px; padding-top:15px; color:#136a92;} 188 151 .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;} 192 155 .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; } 193 156 .identity-plus-main-fm .cert {max-width:600px; border-radius:3px; float:left; clear:both;} 194 157 .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;} 196 159 .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;} 198 161 .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;} 199 169 </style> 200 170 <?php … … 206 176 ?> 207 177 <form class="identity-plus-main-fm" action='options.php' method='post' enctype="multipart/form-data"> 208 <h1 >Identity +</h1>209 <h5> ofman & machine</h5>178 <h1 class="identity-plus-brand">Identity<span>plus</span></h1> 179 <h5>man & machine</h5> 210 180 <?php 211 181 settings_fields( 'identity_plus_cert_section' ); … … 244 214 245 215 216 # -------------------------- Id + Menu Page 217 218 add_action( 'admin_action_identity_plus_connect', 'identity_plus_connect'); 219 function 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 243 add_action( 'admin_action_identity_plus_disconnect', 'identity_plus_disconnect'); 244 function 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 269 add_action( 'admin_menu', 'identity_plus_add_idp_page' ); 270 271 function 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+PHN2ZyAgIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIiAgIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyIgICB4bWxuczpzdmc9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgICB4bWxuczpzb2RpcG9kaT0iaHR0cDovL3NvZGlwb2RpLnNvdXJjZWZvcmdlLm5ldC9EVEQvc29kaXBvZGktMC5kdGQiICAgeG1sbnM6aW5rc2NhcGU9Imh0dHA6Ly93d3cuaW5rc2NhcGUub3JnL25hbWVzcGFjZXMvaW5rc2NhcGUiICAgdmVyc2lvbj0iMS4xIiAgIGlkPSJMYXllcl8xIiAgIHg9IjBweCIgICB5PSIwcHgiICAgd2lkdGg9IjEyOHB4IiAgIGhlaWdodD0iMTI4cHgiICAgdmlld0JveD0iMCAwIDEyOCAxMjgiICAgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgMTI4IDEyODsiICAgeG1sOnNwYWNlPSJwcmVzZXJ2ZSIgICBpbmtzY2FwZTp2ZXJzaW9uPSIwLjkxIHIxMzcyNSIgICBzb2RpcG9kaTpkb2NuYW1lPSJkYXJrLXBsdXMtc2ltcGxlLnN2ZyI+PG1ldGFkYX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NjIsMS44MzYwNDcgLTEuOTY4NzUsNC41MDI3NjcgLTEuOTY4NzUsOCAwLDMuNDk3MjMzIDAuNjU3Mjg4LDYuMTYzOTUzIDEuOTY4NzUsOCAxLjMzMzMyLDEuODM2MDQ3IDMuMjQ0NTUsMi43NTM5MDYgNS43MzYzMjgsMi43NTM5MDYgMi41MTM2MzYsMCA0LjQyNjgxOSwtMC45MTc4NTkgNS43MzgyODEsLTIuNzUzOTA2IDEuMzMzMzIsLTEuODM2MDQ3IDIsLTQuNTAyNzY3IDIsLTggMCwtMy40OTcyMzMgLTAuNjY2NjgsLTYuMTYzOTUzIC0yLC04IC0xLjMxMTQ2MiwtMS44MzYwNDcgLTMuMjI0NjQ1LC0yLjc1MzkwNiAtNS43MzgyODEsLTIuNzUzOTA2IHoiICAgICAgIGlkPSJyZWN0NSIgICAgICAgaW5rc2NhcGU6Y29ubmVjdG9yLWN1cnZhdHVyZT0iMCIgICAgICAgc29kaXBvZGk6bm9kZXR5cGVzPSJjY2NjY2NjY2NjY2NjY2NzY2NjY2NjY2NjY2NjY2NjY2NjY2Njc2NzY3Njc2NzIiAvPjwvZz48ZyAgICAgaWQ9ImcyNSIgLz48ZyAgICAgaWQ9ImcyNyIgLz48ZyAgICAgaWQ9ImcyOSIgLz48ZyAgICAgaWQ9ImczMSIgLz48ZyAgICAgaWQ9ImczMyIgLz48L3N2Zz4=' 281 ); 282 } 283 } 284 285 function 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 348 function 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 & machine</h5> 353 <?php wp_nonce_field('my_delete_action'); ?> 354 <?php identity_plus_idp_page(); ?> 355 </form> 356 <?php 357 } 358 359 246 360 add_filter('upload_mimes', 'identity_plus_enable_extra_extensions'); 361 -
identity-plus/trunk/readme.txt
r1920096 r1932034 82 82 == Changelog == 83 83 84 == 1.6 == 85 Migrated 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 84 87 = 1.5 = 85 88 Verified compatibility with Wordpress 4.9.8.
Note: See TracChangeset
for help on using the changeset viewer.