Skip to content
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

Added use Management API for user data #368

Merged
merged 1 commit into from
Jan 23, 2018
Merged

Conversation

joshcanhelp
Copy link
Contributor

@joshcanhelp joshcanhelp commented Jan 23, 2018

This PR changes where user information comes from on login. Switching from the Auth API /userinfo to the Management API /users/user_id to get identities.

  • Added WP_Auth0_Api_Client::get_client_token() to quickly get a management token
  • Updated WP_Auth0_Api_Client::resend_verification_email() to use this token function
  • Replaced WP_Auth0_Api_Client::get_user_info() with WP_Auth0_Api_Client::get_user() to return user information during login (management API access is acquired as part of this upgrade), which fixes identities being returned
  • Added read:users as a required scope
  • Updated DB upgrade to use new WP_Auth0_Api_Client::get_client_token() function to confirm that a client_credentials token can be returned

@joshcanhelp joshcanhelp force-pushed the fixed-get-user-identities branch 3 times, most recently from 015bd8f to fd5d0f0 Compare January 23, 2018 16:28
@joshcanhelp joshcanhelp added CH: Fixed and removed WIP labels Jan 23, 2018
@joshcanhelp joshcanhelp added this to the v3-Next milestone Jan 23, 2018
@joshcanhelp joshcanhelp force-pushed the fixed-get-user-identities branch 2 times, most recently from 6f39965 to d552116 Compare January 23, 2018 16:35
…ment token; updated WP_Auth0_Api_Client::resend_verification_email() to use this token function; replaced WP_Auth0_Api_Client::get_user_info() with WP_Auth0_Api_Client::get_user() to return user information during login (management API access is acquired as part of this upgrade), which fixes identities being returned; added read:users as a required scope; updated DB upgrade to use new WP_Auth0_Api_Client::get_client_token() function to confirm that a client_credentials token can be returned.
@joshcanhelp joshcanhelp force-pushed the fixed-get-user-identities branch from d552116 to c68dd4e Compare January 23, 2018 16:36
@joshcanhelp
Copy link
Contributor Author

@cocojoe @glena - After our conversation about the Implicit flow use case, I'm wondering if this (and probably a few other things) needs to get re-worked. Implicit users, if they really are blocked from calling the Auth0 server, won't benefit from a client grant, won't be able to use the resend email verification anyways, and won't have the user information that makes it possible to change password, email, etc. Maybe all of that is expected (maybe not?) in which case we probably need to check for that.

@joshcanhelp joshcanhelp requested review from glena and cocojoe January 23, 2018 16:43
Copy link
Member

@cocojoe cocojoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question. Also I presume you only need openid scope now as you getting email from somewhere else? Shouldn't implicit still require it so it can get from the id_token?

public static function get_client_token() {

$response = wp_remote_post( self::get_endpoint( 'oauth/token' ), array(
'headers' => self::get_headers( '', 'application/x-www-form-urlencoded' ),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is content-type specified?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cocojoe - self::get_headers()

@joshcanhelp
Copy link
Contributor Author

@cocojoe - RE: implicit scope ... it does, look a couple of lines down, you'll see implicit adds additional scopes.

@cocojoe cocojoe changed the title Use Management API to pull logging-in user data [WIP] Use Management API to pull logging-in user data Jan 23, 2018
@cocojoe cocojoe changed the title Use Management API to pull logging-in user data Added use Management API for user data Jan 23, 2018
@cocojoe cocojoe removed the request for review from glena January 23, 2018 21:58
@joshcanhelp joshcanhelp merged commit 26e0539 into dev Jan 23, 2018
@joshcanhelp joshcanhelp deleted the fixed-get-user-identities branch January 23, 2018 22:05
@joshcanhelp
Copy link
Contributor Author

Fixes #348

@cocojoe cocojoe mentioned this pull request Jan 25, 2018
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants