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

[stable28] fix: Add direct parameter to flow auth v2 #47052

Merged
merged 1 commit into from
Aug 7, 2024
Merged
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
10 changes: 6 additions & 4 deletions core/Controller/ClientFlowLoginV2Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,15 @@ public function poll(string $token): JSONResponse {
*/
#[OpenAPI(scope: OpenAPI::SCOPE_IGNORE)]
#[UseSession]
public function landing(string $token, $user = ''): Response {
public function landing(string $token, string $user = '', int $direct = 0): Response {
if (!$this->loginFlowV2Service->startLoginFlow($token)) {
return $this->loginTokenForbiddenResponse();
}

$this->session->set(self::TOKEN_NAME, $token);

return new RedirectResponse(
$this->urlGenerator->linkToRouteAbsolute('core.ClientFlowLoginV2.showAuthPickerPage', ['user' => $user])
$this->urlGenerator->linkToRouteAbsolute('core.ClientFlowLoginV2.showAuthPickerPage', ['user' => $user, 'direct' => $direct])
);
}

Expand All @@ -118,7 +118,7 @@ public function landing(string $token, $user = ''): Response {
*/
#[OpenAPI(scope: OpenAPI::SCOPE_IGNORE)]
#[UseSession]
public function showAuthPickerPage($user = ''): StandaloneTemplateResponse {
public function showAuthPickerPage(string $user = '', int $direct = 0): StandaloneTemplateResponse {
try {
$flow = $this->getFlowByLoginToken();
} catch (LoginFlowV2NotFoundException $e) {
Expand All @@ -140,6 +140,7 @@ public function showAuthPickerPage($user = ''): StandaloneTemplateResponse {
'urlGenerator' => $this->urlGenerator,
'stateToken' => $stateToken,
'user' => $user,
'direct' => $direct,
],
'guest'
);
Expand All @@ -152,7 +153,7 @@ public function showAuthPickerPage($user = ''): StandaloneTemplateResponse {
*/
#[OpenAPI(scope: OpenAPI::SCOPE_IGNORE)]
#[UseSession]
public function grantPage(?string $stateToken): StandaloneTemplateResponse {
public function grantPage(?string $stateToken, int $direct = 0): StandaloneTemplateResponse {
if ($stateToken === null) {
return $this->stateTokenMissingResponse();
}
Expand All @@ -179,6 +180,7 @@ public function grantPage(?string $stateToken): StandaloneTemplateResponse {
'instanceName' => $this->defaults->getName(),
'urlGenerator' => $this->urlGenerator,
'stateToken' => $stateToken,
'direct' => $direct,
],
'guest'
);
Expand Down
2 changes: 1 addition & 1 deletion core/templates/loginflowv2/authpicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<br/>

<p id="redirect-link">
<form id="login-form" action="<?php p($urlGenerator->linkToRouteAbsolute('core.ClientFlowLoginV2.grantPage', ['stateToken' => $_['stateToken'], 'user' => $_['user']])) ?>" method="get">
<form id="login-form" action="<?php p($urlGenerator->linkToRouteAbsolute('core.ClientFlowLoginV2.grantPage', ['stateToken' => $_['stateToken'], 'user' => $_['user'], 'direct' => $_['direct'] ?? 0])) ?>" method="get">
<input type="submit" class="login primary icon-confirm-white" value="<?php p($l->t('Log in')) ?>" disabled>
</form>
</p>
Expand Down
3 changes: 3 additions & 0 deletions core/templates/loginflowv2/grant.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
<form method="POST" action="<?php p($urlGenerator->linkToRouteAbsolute('core.ClientFlowLoginV2.generateAppPassword')) ?>">
<input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']) ?>" />
<input type="hidden" name="stateToken" value="<?php p($_['stateToken']) ?>" />
<?php if ($_['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>
Expand Down
Loading