Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,7 @@ public function __construct(string $appName, array $urlParams = [], ?ServerConta
)
);

$dispatcher->registerMiddleware(
new FlowV2EphemeralSessionsMiddleware(
$c->get(ISession::class),
$c->get(IUserSession::class),
)
);
$dispatcher->registerMiddleware($c->get(FlowV2EphemeralSessionsMiddleware::class));

$securityMiddleware = new SecurityMiddleware(
$c->get(IRequest::class),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/
namespace OC\AppFramework\Middleware;

use OC\AppFramework\Utility\ControllerMethodReflector;
use OC\Core\Controller\ClientFlowLoginV2Controller;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Middleware;
Expand All @@ -20,6 +21,7 @@ class FlowV2EphemeralSessionsMiddleware extends Middleware {
public function __construct(
private ISession $session,
private IUserSession $userSession,
private ControllerMethodReflector $reflector,
) {
}

Expand All @@ -40,6 +42,10 @@ public function beforeController(Controller $controller, string $methodName) {
return;
}

if ($this->reflector->hasAnnotation('PublicPage')) {
return;
}

$this->userSession->logout();
$this->session->close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@

use OC\Core\Controller\ClientFlowLoginV2Controller;
use OCP\ISession;
use OCP\IURLGenerator;

class FlowV2EphemeralSessionsCommand extends ALoginCommand {
public function __construct(
private ISession $session,
private IURLGenerator $urlGenerator,
) {
}

public function process(LoginData $loginData): LoginResult {
if (str_starts_with($loginData->getRedirectUrl() ?? '', '/login/v2/grant')) {
$loginV2GrantRoute = $this->urlGenerator->linkToRoute('core.ClientFlowLoginV2.grantPage');
if (str_starts_with($loginData->getRedirectUrl() ?? '', $loginV2GrantRoute)) {
$this->session->set(ClientFlowLoginV2Controller::EPHEMERAL_NAME, true);
}

Expand Down
Loading