Skip to content

Improve OAuth handling - #9517

Merged
rullzer merged 6 commits into
masterfrom
feature/noid/improve_oauth_handling
May 22, 2018
Merged

Improve OAuth handling#9517
rullzer merged 6 commits into
masterfrom
feature/noid/improve_oauth_handling

Conversation

@rullzer

Copy link
Copy Markdown
Member

No description provided.

@rullzerrullzer added enhancement 3. to review Waiting for reviews labels May 18, 2018
@rullzerrullzer added this to the Nextcloud 14 milestone May 18, 2018

@blizzzblizzz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

cannot say much about it… but at least some bikeshedding

public function authorize($client_id,
$state) {
$state,
$response_type) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

camelCase?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

No I can't change those as they are post variables and defined in the OAuth spec

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

okay then

*/
public function getToken($code) {
$accessToken = $this->accessTokenMapper->getByCode($code);
public function getToken($grant_type, $code, $refresh_token, $client_id, $client_secret) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

cases

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

No I can't change those as they are post variables and defined in the OAuth spec

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

okay then

// Set the 3600 second timeout on all tokens
foreach ($tokens as $token) {
try {
$appToken = $this->tokenProvider->getTokenById($token->getTokenId());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

would it have a better memory footprint if we deal with that inside the while-loop above?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

yes fair enough let me fix that...

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

done

@rullzer
rullzerforce-pushed the feature/noid/improve_oauth_handling branch from 3580a75 to a7568bcCompareMay 18, 2018 11:05
@codecov

codecovBot commented May 18, 2018

Copy link
Copy Markdown

Codecov Report

❗ No coverage uploaded for pull request base (master@bbcb36c). Click here to learn what that means.
The diff coverage is 59.49%.

@@ Coverage Diff @@## master #9517 +/- ##
========================================
Coverage ? 51.7% Complexity ? 25757 ========================================
Files ? 1644 Lines ? 96569 Branches ? 1393 ========================================
Hits ? 49932 Misses ? 46637 Partials ? 0
Impacted FilesCoverage ΔComplexity Δ
apps/oauth2/composer/composer/autoload_static.php0% <ø> (ø)1 <0> (?)
apps/oauth2/lib/Migration/SetTokenExpiration.php0% <0%> (ø)5 <5> (?)
...pps/oauth2/composer/composer/autoload_classmap.php0% <0%> (ø)0 <0> (?)
core/Controller/ClientFlowLoginController.php72.72% <100%> (ø)28 <0> (?)
...auth2/lib/Controller/LoginRedirectorController.php71.42% <60%> (ø)3 <0> (?)
apps/oauth2/lib/Controller/OauthApiController.php84.61% <86%> (ø)11 <10> (?)

}

// The client id and secret must match. Else we don't provide an access token!
if ($client->getClientIdentifier() !== $client_id || $client->getSecret() !== $client_secret) {

@blizzzblizzzMay 18, 2018

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

with grant_type = 'refresh_token' client_id and and secret are not provided. Unless I oversaw a thing? yes, i did, all right

@blizzzblizzz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

looks good to me

@ChristophWurstChristophWurst left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Code looks good

Found one unused variable


$cursor = $qb->execute();

$tokens = [];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

unused

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Fixed

rullzer added 6 commits May 22, 2018 09:24
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
On a refresh token request:
* rorate
* reset expire
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
@rullzer
rullzerforce-pushed the feature/noid/improve_oauth_handling branch from a7568bc to 461998dCompareMay 22, 2018 07:24
@blizzzblizzz added 4. to release Ready to be released and/or waiting for tests to finish and removed 3. to review Waiting for reviews labels May 22, 2018
@rullzer
rullzer merged commit 57d4a16 into masterMay 22, 2018
@rullzer
rullzer deleted the feature/noid/improve_oauth_handling branch May 22, 2018 08:16
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4. to releaseReady to be released and/or waiting for tests to finishenhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@rullzer@ChristophWurst@blizzz