-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
10upbot on GitHub
committed
Jul 2, 2020
1 parent
459668f
commit 3465389
Showing
24 changed files
with
5,962 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
load File.join( | ||
File.dirname(__FILE__), | ||
"vendor/wpsh/local/Vagrantfile" | ||
) | ||
|
||
Vagrant.configure(2) do |config| | ||
config.vm.hostname = "application-passwords" | ||
end |
13 changes: 13 additions & 0 deletions
13
vendor/georgestephanis/application-passwords/application-passwords.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
.app-pass-dialog-background { | ||
opacity: 1.0; | ||
background: rgba(0,0,0,0.7); | ||
} | ||
|
||
.app-pass-dialog { | ||
padding: 20px; | ||
} | ||
|
||
.new-application-password-content { | ||
padding-bottom: 20px; | ||
padding-top: 10px; | ||
} |
128 changes: 128 additions & 0 deletions
128
vendor/georgestephanis/application-passwords/application-passwords.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
/* global appPass, wp */ | ||
( function( $, appPass ) { | ||
var $appPassSection = $( '#application-passwords-section' ), | ||
$newAppPassForm = $appPassSection.find( '.create-application-password' ), | ||
$newAppPassField = $newAppPassForm.find( '.input' ), | ||
$newAppPassButton = $newAppPassForm.find( '.button' ), | ||
$appPassTwrapper = $appPassSection.find( '.application-passwords-list-table-wrapper' ), | ||
$appPassTbody = $appPassSection.find( 'tbody' ), | ||
$appPassTrNoItems = $appPassTbody.find( '.no-items' ), | ||
$removeAllBtn = $( '#revoke-all-application-passwords' ), | ||
tmplNewAppPass = wp.template( 'new-application-password' ), | ||
tmplAppPassRow = wp.template( 'application-password-row' ), | ||
tmplNotice = wp.template( 'application-password-notice' ), | ||
testBasicAuthUser = Math.random().toString( 36 ).replace( /[^a-z]+/g, '' ), | ||
testBasicAuthPassword = Math.random().toString( 36 ).replace( /[^a-z]+/g, '' ); | ||
|
||
$.ajax( { | ||
url: appPass.root + appPass.namespace + '/test-basic-authorization-header', | ||
method: 'POST', | ||
beforeSend: function( xhr ) { | ||
xhr.setRequestHeader( 'Authorization', 'Basic ' + btoa( testBasicAuthUser + ':' + testBasicAuthPassword ) ); | ||
}, | ||
error: function( jqXHR ) { | ||
if ( 404 === jqXHR.status ) { | ||
$newAppPassForm.before( tmplNotice( { | ||
type: 'error', | ||
message: appPass.text.no_credentials | ||
} ) ); | ||
} | ||
} | ||
} ).done( function( response ) { | ||
if ( response.PHP_AUTH_USER === testBasicAuthUser && response.PHP_AUTH_PW === testBasicAuthPassword ) { | ||
// Save the success in SessionStorage or the like, so we don't do it on every page load? | ||
} else { | ||
$newAppPassForm.before( tmplNotice( { | ||
type: 'error', | ||
message: appPass.text.no_credentials | ||
} ) ); | ||
} | ||
} ); | ||
|
||
$newAppPassButton.click( function( e ) { | ||
e.preventDefault(); | ||
var name = $newAppPassField.val(); | ||
|
||
if ( 0 === name.length ) { | ||
$newAppPassField.focus(); | ||
return; | ||
} | ||
|
||
$newAppPassField.prop( 'disabled', true ); | ||
$newAppPassButton.prop( 'disabled', true ); | ||
|
||
$.ajax( { | ||
url: appPass.root + appPass.namespace + '/application-passwords/' + appPass.user_id + '/add', | ||
method: 'POST', | ||
beforeSend: function( xhr ) { | ||
xhr.setRequestHeader( 'X-WP-Nonce', appPass.nonce ); | ||
}, | ||
data: { | ||
name: name | ||
} | ||
} ).done( function( response ) { | ||
$newAppPassField.prop( 'disabled', false ).val( '' ); | ||
$newAppPassButton.prop( 'disabled', false ); | ||
|
||
$newAppPassForm.after( tmplNewAppPass( { | ||
name: name, | ||
password: response.password | ||
} ) ); | ||
|
||
$appPassTbody.prepend( tmplAppPassRow( response.row ) ); | ||
|
||
$appPassTwrapper.show(); | ||
$appPassTrNoItems.remove(); | ||
} ); | ||
} ); | ||
|
||
$appPassTbody.on( 'click', '.delete', function( e ) { | ||
e.preventDefault(); | ||
var $tr = $( e.target ).closest( 'tr' ), | ||
slug = $tr.data( 'slug' ); | ||
|
||
$.ajax( { | ||
url: appPass.root + appPass.namespace + '/application-passwords/' + appPass.user_id + '/' + slug, | ||
method: 'DELETE', | ||
beforeSend: function( xhr ) { | ||
xhr.setRequestHeader( 'X-WP-Nonce', appPass.nonce ); | ||
} | ||
} ).done( function( response ) { | ||
if ( response ) { | ||
if ( 0 === $tr.siblings().length ) { | ||
$appPassTwrapper.hide(); | ||
} | ||
$tr.remove(); | ||
} | ||
} ); | ||
} ); | ||
|
||
$removeAllBtn.on( 'click', function( e ) { | ||
e.preventDefault(); | ||
|
||
$.ajax( { | ||
url: appPass.root + appPass.namespace + '/application-passwords/' + appPass.user_id, | ||
method: 'DELETE', | ||
beforeSend: function( xhr ) { | ||
xhr.setRequestHeader( 'X-WP-Nonce', appPass.nonce ); | ||
} | ||
} ).done( function( response ) { | ||
if ( parseInt( response, 10 ) > 0 ) { | ||
$appPassTbody.children().remove(); | ||
$appPassSection.children( '.new-application-password' ).remove(); | ||
$appPassTwrapper.hide(); | ||
} | ||
} ); | ||
} ); | ||
|
||
$( document ).on( 'click', '.application-password-modal-dismiss', function( e ) { | ||
e.preventDefault(); | ||
|
||
$( '.new-application-password.notification-dialog-wrap' ).hide(); | ||
} ); | ||
|
||
// If there are no items, don't display the table yet. If there are, show it. | ||
if ( 0 === $appPassTbody.children( 'tr' ).not( $appPassTrNoItems ).length ) { | ||
$appPassTwrapper.hide(); | ||
} | ||
}( jQuery, appPass ) ); |
17 changes: 17 additions & 0 deletions
17
vendor/georgestephanis/application-passwords/application-passwords.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
/** | ||
* Plugin Name: Application Passwords | ||
* Plugin URI: https://github.com/WordPress/application-passwords | ||
* Description: Creates unique passwords for applications to authenticate users without revealing their main passwords. | ||
* Author: George Stephanis | ||
* Version: 0.1.1 | ||
* Author URI: https://github.com/georgestephanis | ||
*/ | ||
|
||
define( 'APPLICATION_PASSWORDS_VERSION', '0.1.0' ); | ||
|
||
/** | ||
* Include the application passwords system. | ||
*/ | ||
require_once( dirname( __FILE__ ) . '/class.application-passwords.php' ); | ||
Application_Passwords::add_hooks(); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.