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

Set 'app_password' in session only when using a permanent token #29729

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2381,7 +2381,7 @@
</RedundantCondition>
</file>
<file src="lib/private/Authentication/Token/PublicKeyToken.php">
<UndefinedMethod occurrences="16">
<UndefinedMethod occurrences="17">
<code>parent::getExpires()</code>
<code>parent::getLastCheck()</code>
<code>parent::getLoginName()</code>
Expand All @@ -2398,6 +2398,7 @@
<code>parent::setScope(json_encode($scope))</code>
<code>parent::setToken($token)</code>
<code>parent::setType(IToken::WIPE_TOKEN)</code>
<code>parent::getType()</code>
</UndefinedMethod>
</file>
<file src="lib/private/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDao.php">
Expand Down
8 changes: 8 additions & 0 deletions lib/private/Authentication/Token/IToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ public function getName(): string;
*/
public function getRemember(): int;

/**
* Get the token type
*
* @return int
* @psalm-return IToken::DO_NOT_REMEMBER|IToken::REMEMBER
*/
public function getType(): int;

/**
* Set the token
*
Expand Down
5 changes: 4 additions & 1 deletion lib/private/Authentication/Token/PublicKeyToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
* @method void setLoginName(string $loginname)
* @method string getToken()
* @method void setType(int $type)
* @method int getType()
* @method void setRemember(int $remember)
* @method void setLastActivity(int $lastactivity)
* @method int getLastActivity()
Expand Down Expand Up @@ -201,6 +200,10 @@ public function setName(string $name): void {
parent::setName($name);
}

public function getType(): int {
return parent::getType();
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Show resolved Hide resolved
}

public function getRemember(): int {
return parent::getRemember();
}
Expand Down
3 changes: 1 addition & 2 deletions lib/private/User/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -835,8 +835,7 @@ public function tryTokenLogin(IRequest $request) {
return true;
}

// Remember me tokens are not app_passwords
if ($dbToken->getRemember() === IToken::DO_NOT_REMEMBER) {
if ($dbToken->getType() === IToken::PERMANENT_TOKEN) {
// Set the session variable so we know this is an app password
$this->session->set('app_password', $token);
}
Expand Down