-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement wp-login.php based cookie authentication #327
Open
crazytonyli
wants to merge
28
commits into
trunk
Choose a base branch
from
wp-login-cookie-authentication
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 11 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
de6b9a0
Implement wp-login.php based cookie authentication
crazytonyli 97c9bbf
Add a few integration tests for cookie authentication
crazytonyli b3e0d05
Implement authentication methods in dedicated types
crazytonyli 5d977f2
Save fetched nonce
crazytonyli 1366c95
Merge branch 'trunk' into wp-login-cookie-authentication
crazytonyli f8e73e6
Add TestCredentials.admin_account_password
crazytonyli 2721dfd
Do not mutate request in Authenticator
crazytonyli aeb2ae5
Add unit tests for derived url functions
crazytonyli a0613fd
Format code
crazytonyli 083a7d3
Add a constrant for "application/x-www-form-urlencoded"
crazytonyli bf61854
Derive Default on InnerRequestBuilder
crazytonyli 2cba32e
Refactor authenticator to extra authentication logic
crazytonyli 52c8a5c
Remove AuthenticationError
crazytonyli 06ef60d
Add an unit test to verify nonce is reused across multiple requests
crazytonyli 527c176
Prevent repeatedly fetching nonce when sending concurrent requests
crazytonyli 53f6f66
Replace empty default value with assertions
crazytonyli 1d0c91c
Clone instead of re-creating ApiBaseUrl
crazytonyli 9ca673b
Run cookie authentication tests in parallel
crazytonyli 776ba65
Add an API to document RequestExecutor must support cookie-jar
crazytonyli 3112f32
Update function parameters
crazytonyli 3fcdda3
Rename get_reset_nonce to fetch_rest_nonce
crazytonyli 0afe44d
Merge branch 'trunk' into wp-login-cookie-authentication
crazytonyli c30f3fb
Add more test cases to wp-login and rest-nonce unit tests
crazytonyli a5884e7
Simplify deriving wp-login url implementation
crazytonyli 86caf42
Simplify Authenticator trait design
crazytonyli 2bf1ec5
Fix a compiling issue
crazytonyli 40404ff
Pass previous authentication header instead of the request object
crazytonyli 012a36a
Add unit tests for CookieAuthenticator
crazytonyli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
set -e | ||
|
||
# This script sets up a WordPress test site on the `wordpress` docker image. | ||
# This script sets up a WordPress test site on the `wordpress` docker image. | ||
# You might wonder "why not do this work once, then just import the database for each run?" | ||
# We do each step each time for each build because we're trying to get a "mint" condition site | ||
# for each WordPress version – if there are issues with DB migrations, different default themes | ||
|
@@ -41,13 +41,16 @@ echo "--- :wordpress: Setting up WordPress" | |
wp core version --extra | ||
wp --info | ||
|
||
ADMIN_USERNAME="[email protected]" | ||
ADMIN_ACCOUNT_PASSWORD="strongpassword" | ||
|
||
## Install WordPress | ||
wp core install \ | ||
--url=localhost \ | ||
--title=my-test-site \ | ||
--admin_user=[email protected] \ | ||
--admin_email=[email protected] \ | ||
--admin_password=strongpassword \ | ||
--admin_user=$ADMIN_USERNAME \ | ||
--admin_email=$ADMIN_USERNAME \ | ||
--admin_password=$ADMIN_ACCOUNT_PASSWORD \ | ||
--skip-email | ||
|
||
## Ensure URLs work as expected | ||
|
@@ -76,7 +79,6 @@ wp user create test_author [email protected] --role=author | |
|
||
create_test_credentials () { | ||
local SITE_URL | ||
local ADMIN_USERNAME | ||
local ADMIN_PASSWORD_UUID | ||
local ADMIN_PASSWORD | ||
local SUBSCRIBER_USERNAME | ||
|
@@ -85,9 +87,8 @@ create_test_credentials () { | |
local TRASHED_POST_ID | ||
local PASSWORD_PROTECTED_POST_ID | ||
SITE_URL="http://localhost" | ||
ADMIN_USERNAME="[email protected]" | ||
ADMIN_PASSWORD="$(wp user application-password create [email protected] test --porcelain)" | ||
ADMIN_PASSWORD_UUID="$(wp user application-password list [email protected] --fields=uuid --format=csv | sed -n '2 p')" | ||
ADMIN_PASSWORD="$(wp user application-password create $ADMIN_USERNAME test --porcelain)" | ||
ADMIN_PASSWORD_UUID="$(wp user application-password list $ADMIN_USERNAME --fields=uuid --format=csv | sed -n '2 p')" | ||
SUBSCRIBER_USERNAME="themedemos" | ||
SUBSCRIBER_PASSWORD="$(wp user application-password create themedemos test --porcelain)" | ||
SUBSCRIBER_PASSWORD_UUID="$(wp user application-password list themedemos --fields=uuid --format=csv | sed -n '2 p')" | ||
|
@@ -104,6 +105,7 @@ create_test_credentials () { | |
jo -p \ | ||
site_url="$SITE_URL" \ | ||
admin_username="$ADMIN_USERNAME" \ | ||
admin_account_password="$ADMIN_ACCOUNT_PASSWORD" \ | ||
admin_password="$ADMIN_PASSWORD" \ | ||
admin_password_uuid="$ADMIN_PASSWORD_UUID" \ | ||
subscriber_username="$SUBSCRIBER_USERNAME" \ | ||
|
@@ -131,4 +133,3 @@ wp option update timezone_string "America/New_York" | |
cp -rp wp-content/plugins wp-content/plugins-backup | ||
|
||
wp db export --add-drop-table wp-content/dump.sql | ||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we clone the
Arc<ParsedUrl>
instead ofinner
?