Skip to content

Satisfy @PasswordConfirmationRequired when authenticating with Bearer Authorization header - #7501

Closed
DamnDam wants to merge 2 commits into
nextcloud:masterfrom
DamnDam:DamnDam-patch-oauth
Closed

Satisfy @PasswordConfirmationRequired when authenticating with Bearer Authorization header#7501
DamnDam wants to merge 2 commits into
nextcloud:masterfrom
DamnDam:DamnDam-patch-oauth

Conversation

@DamnDam

@DamnDamDamnDam commented Dec 13, 2017

Copy link
Copy Markdown

Issue:

When authenticated with an access token in a Bearer Authorization header in a stateless context, it is impossible to satisfy @PasswordConfirmationRequired routes.

Proposed solution:

When authenticating a Bearer Authorization Header, update the 'last-password-confirm' session variable, in the same way as a Basic Authorization.

@DamnDamDamnDam changed the title Satisfy \@PasswordConfirmationRequired when authenticating with Bearer Authorization headerSatisfy @PasswordConfirmationRequired when authenticating with Bearer Authorization headerDec 13, 2017
@MorrisJobkeMorrisJobke added the 3. to review Waiting for reviews label Dec 14, 2017
@DamnDam

Copy link
Copy Markdown
Author

This is relevant for OAuth2 authentication, especially as an admin @LukasReschke

@DamnDam

Copy link
Copy Markdown
Author

This should fix the same issue as #7487

Comment threadlib/private/User/Session.php Outdated
if(!$this->validateToken($token)) {
return false;
}
$this->session->set('last-password-confirm', $this->timeFactory->getTime());

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 like this line is also hit for simple browser sessions (line 737 and below) and thus completely disables the password confirmation feature.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Right, sorry about that!

@ChristophWurstChristophWurst added 1. to develop Accepted and waiting to be taken care of and removed 3. to review Waiting for reviews labels Dec 18, 2017
@codecov

codecovBot commented Jan 2, 2018

Copy link
Copy Markdown

Codecov Report

Merging #7501 into master will increase coverage by <.01%.
The diff coverage is 0%.

@@ Coverage Diff @@## master #7501 +/- ##
============================================
+ Coverage 51.1% 51.11% +<.01% 
Complexity 24903 24903 ============================================
Files 1601 1601 Lines 94779 94780 +1 Branches 1368 1368 ============================================
+ Hits 48439 48443 +4 + Misses 46340 46337 -3
Impacted FilesCoverage ΔComplexity Δ
lib/private/User/Session.php73.91% <0%> (-0.24%)116 <0> (ø)
lib/private/Security/CertificateManager.php91.08% <0%> (-1%)39% <0%> (ø)
apps/files_trashbin/lib/Trashbin.php72.28% <0%> (-0.25%)136% <0%> (ø)
lib/private/Server.php81.01% <0%> (+0.11%)134% <0%> (ø)⬇️
core/js/js.js63.55% <0%> (+0.56%)0% <0%> (ø)⬇️

return false;
}

if($loginWithHeader) {

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.

this variable is not set on all previous code paths. it should be initialized with false at the beginning of the method body.

@ChristophWurstChristophWurst added 2. developing Work in progress and removed 1. to develop Accepted and waiting to be taken care of labels Jan 5, 2018
@rullzer

Copy link
Copy Markdown
Member

Since #7487 is in. Lets close this.

@rullzerrullzer closed this Jan 18, 2018
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2. developingWork in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@DamnDam@rullzer@ChristophWurst@MorrisJobke