-
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
Add /userinfo fallback during login #423
Conversation
@@ -19,9 +19,12 @@ public static function insert_auth0_error( $section, $error ) { | |||
} elseif ( $error instanceof Exception ) { | |||
$code = $error->getCode(); | |||
$message = $error->getMessage(); | |||
} elseif ( is_array( $error ) && ! empty( $error['response'] ) ) { |
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.
Typical response from wp_remote_post()
and wp_remote_get()
7750c08
to
dc1cdc2
Compare
Addresses #401 |
lib/WP_Auth0_Lock10_Options.php
Outdated
protected $signup_mode = false; | ||
protected $_id_token_scopes = 'openid email email_verified name nickname picture'; |
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.
why id_token_scopes btw and not just scopes?
$userinfo_resp_body = wp_remote_retrieve_body( $userinfo_resp ); | ||
|
||
// Management API call failed | ||
// Management API call failed, fallback to userinfo |
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.
So why does Management API fail?
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.
This is something we should have had in 3.5.0. It will fail if the Client/Application is not authorized on the Management API or if Client Grant has not been turned on. Has been a common support theme and wanted to get it in there for anyone else upgrading.
dc1cdc2
to
192a388
Compare
lib/WP_Auth0_ErrorManager.php
Outdated
@@ -19,9 +19,12 @@ public static function insert_auth0_error( $section, $error ) { | |||
} elseif ( $error instanceof Exception ) { | |||
$code = $error->getCode(); | |||
$message = $error->getMessage(); | |||
} elseif ( is_array( $error ) && ! empty( $error['response'] ) ) { | |||
$code = ! empty( $error['response']['code'] ) ? $error['response']['code'] : 'N/A'; |
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.
Instead of N/A
use something like a0_unknown_code
or if you received a "plain text response" then use that as description and use some code like a0_plaintext_error
lib/WP_Auth0_ErrorManager.php
Outdated
@@ -19,9 +19,12 @@ public static function insert_auth0_error( $section, $error ) { | |||
} elseif ( $error instanceof Exception ) { | |||
$code = $error->getCode(); | |||
$message = $error->getMessage(); | |||
} elseif ( is_array( $error ) && ! empty( $error['response'] ) ) { | |||
$code = ! empty( $error['response']['code'] ) ? $error['response']['code'] : 'N/A'; | |||
$message = ! empty( $error['response']['message'] ) ? $error['response']['message'] : 'N/A'; |
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.
this one is fine, it makes sense.
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.
scope issues
lib/WP_Auth0_Lock10_Options.php
Outdated
protected $signup_mode = false; | ||
protected $_scopes = 'openid email email_verified name nickname picture'; |
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.
email_verified
included in email
lib/WP_Auth0_Lock_Options.php
Outdated
protected $signup_mode = false; | ||
protected $_id_token_scopes = 'openid email email_verified name nickname picture'; |
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.
Same scope comment
@@ -245,30 +244,29 @@ public function redirect_login() { | |||
|
|||
// Attempt to authenticate with the Management API | |||
$client_credentials_token = WP_Auth0_Api_Client::get_client_token(); | |||
$userinfo_resp = null; | |||
$userinfo_resp_code = $userinfo_resp_body = null; |
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.
what's this 2 =
assignment?
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.
Equivalent to:
$userinfo_resp_code = null;
$userinfo_resp_body = null;
9850da0
to
c721384
Compare
Some customers are having trouble with the upgrade process in 3.5.2 while others made make changes to their account disabling management API access. This fallback allows user data to be pulled for logging-in users. Also adds requested scopes for auth code login to make this possible.
c721384
to
4d00d5e
Compare
Some customers are having trouble with the upgrade process in 3.5.2 while others made make changes to their account disabling management API access. This fallback allows user data to be pulled for logging-in users. Also adds requested scopes for auth code login to make this possible and updates the error manager class to handle a common error case.