-
Notifications
You must be signed in to change notification settings - Fork 96
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
Refactor migration token validation and match entire token on endpoints #602
Conversation
@@ -158,7 +158,7 @@ protected function getAuthorizationHeader() { | |||
protected function migration_ws_login() { | |||
|
|||
// Migration web service is not turned on. | |||
if ( $this->a0_options->get( 'migration_ws' ) == 0 ) { | |||
if ( ! $this->a0_options->get( 'migration_ws' ) ) { |
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.
More accurate checking for this setting.
72385a1
to
7cb8902
Compare
@@ -173,18 +173,13 @@ protected function migration_ws_login() { | |||
$authorization = $this->getAuthorizationHeader(); | |||
$authorization = trim( str_replace( 'Bearer ', '', $authorization ) ); | |||
|
|||
$secret = $this->a0_options->get_client_secret_as_key( true ); |
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.
Moved to $this->valid_token
@@ -223,7 +218,7 @@ protected function migration_ws_login() { | |||
protected function migration_ws_get_user() { | |||
|
|||
// Migration web service is not turned on. | |||
if ( $this->a0_options->get( 'migration_ws' ) == 0 ) { |
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.
More accurate checking for this setting.
@@ -705,63 +706,51 @@ public function basic_validation( $old_options, $input ) { | |||
return $input; | |||
} | |||
|
|||
public function migration_ws_validation( $old_options, $input ) { |
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.
Rewritten, probably best to review the final file.
7cb8902
to
c31607f
Compare
@@ -237,21 +232,15 @@ protected function migration_ws_get_user() { | |||
|
|||
$authorization = $this->getAuthorizationHeader(); | |||
$authorization = trim( str_replace( 'Bearer ', '', $authorization ) ); | |||
|
|||
$secret = $this->a0_options->get_client_secret_as_key( true ); |
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.
Moved to $this->valid_token
c31607f
to
224c436
Compare
Codecov Report
@@ Coverage Diff @@
## master #602 +/- ##
============================================
+ Coverage 33.19% 34.02% +0.82%
- Complexity 1313 1317 +4
============================================
Files 54 54
Lines 4191 4174 -17
============================================
+ Hits 1391 1420 +29
+ Misses 2800 2754 -46
Continue to review full report at Codecov.
|
224c436
to
9651ae4
Compare
* | ||
* @return bool | ||
*/ | ||
private function valid_token( $authorization ) { |
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.
It possible to end up in some kind of RS256 situation? or it can only ever be HS256?
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.
No. Original token was always created with HS256 but this new version compares char to char so the algorithm doesn't matter any longer.
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.
Thought I had already approved this last night 😄
Changes
This PR makes changes to how the migration token is used for user migration scenarios:
jti
attribute.Testing
Checklist