-
Notifications
You must be signed in to change notification settings - Fork 1
Conversation
b4c123d
to
5a0127f
Compare
1e2ae8f
to
e8358d7
Compare
4ab510c
to
290fd6f
Compare
/** | ||
* List of errors that were encountered during the validation process. | ||
* | ||
* @var array |
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.
You're switching up the doc style here. This should probably look like:
/**
* @var array List of errors that were encountered during the validation process.
*/
public static function extractClientID($jwt) { | ||
$parts = explode('.', $jwt); | ||
if (count($parts) !== 3) { | ||
throw new Exception('Wrong number of segments.'); |
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.
Is there an Exception
class available while you're in the Vanilla\VanillaConnect
namespace? I think you might be missing use Exception
in this class file.
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.
Addressed
} | ||
|
||
/** | ||
* @return string |
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.
Need a description for this method. There are several more instances, below, that also need descriptions.
public function createRequestAuthJWT($nonce, array $extraClaimItems = []) { | ||
$authHeader = array_merge( | ||
self::JWT_REQUEST_HEADER_TEMPLATE, | ||
['azp' => $this->clientID] |
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 this fail if $clientID
hasn't been set? This same question applies to the createResponseAuthJWT
method.
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 is not possible to not set the clientID since it is required by the constructor.
I'll add exception to the constructor to make sure that no one does:
new VanillaConnect(null, '');
* @param array $jwtHeader Array that will receive the JWT header's content on success. | ||
* @return array|bool The decoded payload or false otherwise. | ||
*/ | ||
public function validateRequest($jwt, &$jwtClaim=[], &$jwtHeader=[]) { |
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 give the equal signs a little space
* It is a pretty loose regex that should enforce what is needed without blocked weird cases. | ||
* | ||
* One line regex: | ||
* /^(?<scheme>(?:https?:)?\/\/)(?:[^\s]+?@)?(?<host>[^\/\s]+)(?<path>\/[^?#\s]*)$/ |
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.
I appreciate the one-liner, but it looks to be missing the userpwd
portion.
/** | ||
* VanillaConnectProvider constructor. | ||
* | ||
* @param string S$clientID |
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.
I think an S got away from you.
|
||
if ($urlEncodingError) { | ||
$errors['request_invalid_redirect_tip'] = | ||
"Seems like the redirect URL was not properly encoded. Invalid character detected."; |
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'd you go with the "double quote" string syntax here?
if ($this->vanillaConnect->validateRequest($requestJWT, $authClaim)) { | ||
$nonce = $authClaim['nonce']; | ||
} else { | ||
$errors = $this->vanillaConnect->getErrors(); |
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.
We're recording specific errors in this function and then potentially overwriting all of them with whatever comes back from VanillaConnect
.
$claim = ['errors' => $errors]; | ||
} | ||
|
||
$responseJWT = $this->vanillaConnect->createResponseAuthJWT($nonce, $claim); |
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.
For the sake of my IDE, can we set $nonce
to null
by default, so there's no perceived chanced it might not be set?
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.
Your IDE is stupid :P. There is no codepath where $nonce is not set.
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.
She's just sensitive, because the only times she sees it getting set are inside an if conditional block
Information
Original spec:
Read the README.md
Notable differences:
?jwt
instead of?sso
since the latter is reserved to jsConnectpush sso
/embed
TODO
How to test
You can see the library used here and here as a pushsso.