Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 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
9 changes: 7 additions & 2 deletions core/Controller/ClientFlowLoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,11 @@ private function stateTokenForbiddenResponse() {
* @UseSession
*
* @param string $clientIdentifier
* @param int $direct
*
* @return StandaloneTemplateResponse
*/
public function showAuthPickerPage($clientIdentifier = '') {
public function showAuthPickerPage($clientIdentifier = '', $direct = 0) {
$clientName = $this->getClientName();
$client = null;
if ($clientIdentifier !== '') {
Expand Down Expand Up @@ -218,6 +219,7 @@ public function showAuthPickerPage($clientIdentifier = '') {
'stateToken' => $stateToken,
'serverHost' => $this->getServerPath(),
'oauthState' => $this->session->get('oauth.state'),
'direct' => $direct,
],
'guest'
);
Expand All @@ -234,10 +236,12 @@ public function showAuthPickerPage($clientIdentifier = '') {
*
* @param string $stateToken
* @param string $clientIdentifier
* @param int $direct
* @return StandaloneTemplateResponse
*/
public function grantPage($stateToken = '',
$clientIdentifier = '') {
$clientIdentifier = '',
$direct = 0) {
if (!$this->isValidToken($stateToken)) {
return $this->stateTokenForbiddenResponse();
}
Expand Down Expand Up @@ -267,6 +271,7 @@ public function grantPage($stateToken = '',
'stateToken' => $stateToken,
'serverHost' => $this->getServerPath(),
'oauthState' => $this->session->get('oauth.state'),
'direct' => $direct,
],
'guest'
);
Expand Down
7 changes: 6 additions & 1 deletion core/Controller/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,12 @@ private function canResetPassword(?string $passwordLink, ?IUser $user): bool {

private function generateRedirect(?string $redirectUrl): RedirectResponse {
if ($redirectUrl !== null && $this->userSession->isLoggedIn()) {
$location = $this->urlGenerator->getAbsoluteURL($redirectUrl);
$location = null;
if (str_starts_with($redirectUrl, 'http')) {
$location = $redirectUrl;
} else {
$location = $this->urlGenerator->getAbsoluteURL($redirectUrl);
}
// Deny the redirect if the URL contains a @
// This prevents unvalidated redirects like ?redirect_url=:[email protected]
if (strpos($location, '@') === false) {
Expand Down
3 changes: 2 additions & 1 deletion core/templates/loginflow/authpicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<br/>

<p id="redirect-link">
<a href="<?php p($urlGenerator->linkToRoute('core.ClientFlowLogin.grantPage', ['stateToken' => $_['stateToken'], 'clientIdentifier' => $_['clientIdentifier'], 'oauthState' => $_['oauthState']])) ?>">
<a href="<?php p($urlGenerator->linkToRoute('core.ClientFlowLogin.grantPage', ['stateToken' => $_['stateToken'], 'clientIdentifier' => $_['clientIdentifier'], 'oauthState' => $_['oauthState'], 'direct' => $_['direct']])) ?>">
<input type="submit" class="login primary icon-confirm-white" value="<?php p($l->t('Log in')) ?>">
</a>
</p>
Expand All @@ -62,6 +62,7 @@
</p>
<input type="hidden" name="stateToken" value="<?php p($_['stateToken']) ?>" />
<input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']) ?>">
<input type="hidden" name="direct" value="<?php p($_['direct']) ?>">
<input id="submit-app-token-login" type="submit" class="login primary icon-confirm-white" value="<?php p($l->t('Grant access')) ?>">
</form>
</div>
Expand Down
15 changes: 9 additions & 6 deletions core/templates/loginflow/grant.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,17 @@
<br/>

<p id="redirect-link">
<form method="POST" action="<?php p($urlGenerator->linkToRouteAbsolute('core.ClientFlowLogin.generateAppPassword')) ?>">
<input type="hidden" name="clientIdentifier" value="<?php p($_['clientIdentifier']) ?>" />
<input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']) ?>" />
<input type="hidden" name="stateToken" value="<?php p($_['stateToken']) ?>" />
<input type="hidden" name="oauthState" value="<?php p($_['oauthState']) ?>" />
<form method="POST" action="<?php p($urlGenerator->linkToRouteAbsolute('core.ClientFlowLogin.generateAppPassword')) ?>">
<input type="hidden" name="clientIdentifier" value="<?php p($_['clientIdentifier']) ?>" />
<input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']) ?>" />
<input type="hidden" name="stateToken" value="<?php p($_['stateToken']) ?>" />
<input type="hidden" name="oauthState" value="<?php p($_['oauthState']) ?>" />
<?php if (p($_['direct'])) { ?>
<input type="hidden" name="direct" value="1" />
<?php } ?>
<div id="submit-wrapper">
<input type="submit" class="login primary icon-confirm-white" title="" value="<?php p($l->t('Grant access')); ?>" />
</div>
</div>
</form>
</p>
</div>