-
Notifications
You must be signed in to change notification settings - Fork 42
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
Validating redirect_uri according to rfc6749 4.1.3 #45
base: main
Are you sure you want to change the base?
Conversation
private function validate_redirect_uri( $args ) { | ||
$value = $this->get_value(); | ||
|
||
if ( ! empty( $args['redirect_uri'] ) ) { |
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.
Can we invert this check instead to return early?
@@ -108,6 +108,47 @@ public function get_expiration() { | |||
return (int) $value['expiration']; | |||
} | |||
|
|||
private function validate_redirect_uri( $args ) { |
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 should be protected
instead, and should have a phpDoc block.
$redirect_uri = $this->validate_redirect_uri( $client, $redirect_uri ); | ||
if ( is_wp_error( $redirect_uri ) ) { | ||
return $redirect_uri; | ||
if ( ! empty( $redirect_uri ) ) { |
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.
Seems like this should always pass the $redirect_uri
in?
@rmccue fixed it up a bit as suggested. Also if there was no redirect_uri in the initial auth request, but there is one in the access token request and it matches the callbacks registered with the client - it's fine, just for convenience reasons. |
https://tools.ietf.org/html/rfc6749#section-4.1.3
Check whether redirect_uri matches the one in the initial request;
validate_redirect_uri
function does not return a registered callback from the DB anymore, if no redirect_uri has been given, as it is an optional parameter. The name of the function did not explain the behaviour well.#17