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

OAuth2 Login opens in new browser window #19400

Closed
firlevapz opened this issue Feb 10, 2020 · 2 comments · Fixed by #19646
Closed

OAuth2 Login opens in new browser window #19400

firlevapz opened this issue Feb 10, 2020 · 2 comments · Fixed by #19646
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap bug
Milestone

Comments

@firlevapz
Copy link
Contributor

firlevapz commented Feb 10, 2020

Steps to reproduce

  1. Enable Nextcloud as OAuth2 Provider for rocket.chat
  2. Install rocket.chat desktop application (on any platform) and configure to login in nextcloud via OAuth2
  3. Login does not work as the desktop-application tries to open an external window and fails with following error message Access Forbidden State token does not match:
    image

Expected behaviour

The OAuth2 Login from the rocket.chat desktop-app should work

Actual behaviour

The external browser window opens (out of the rocket.chat app) with an error message.
This is because, the rocket.chat app opens links with absolute URLs in a new window, i.e. the external browser window.

Server configuration

Operating system:
Ubuntu-18.04
Web server:
Nginx
Database:
mysql
PHP version:

Nextcloud version: (see Nextcloud admin page)
16.0.8 (also in 17.0.3)
Updated from an older Nextcloud/ownCloud or fresh install:
from snap
Where did you install Nextcloud from:
snap

Proposed Solution

in core/templates/loginflow/authpicker.php change this line

 	<p id="redirect-link">
-		<a href="<?php p($urlGenerator->linkToRouteAbsolute('core.ClientFlowLogin.grantPage', ['stateToken' => $_['stateToken'], 'clientIdentifier' => $_['clientIdentifier'], 'oauthState' => $_['oauthState']])) ?>">
+		<a href="<?php p($urlGenerator->linkToRoute('core.ClientFlowLogin.grantPage', ['stateToken' => $_['stateToken'], 'clientIdentifier' => $_['clientIdentifier'], 'oauthState' => $_['oauthState']])) ?>">
 			<input type="submit" class="login primary icon-confirm-white" value="<?php p($l->t('Log in')) ?>">
 		</a>
 	</p>

I've tested the solution and it solves the problem. Are there any drawbacks to this, otherwise I'd open a pull-request for it.

@firlevapz firlevapz added 0. Needs triage Pending check for reproducibility or if it fits our roadmap bug labels Feb 10, 2020
@firlevapz firlevapz changed the title OAuth2 Login open OAuth2 Login opens in new browser window Feb 10, 2020
@holzhannes
Copy link

holzhannes commented Feb 15, 2020

Issue in Rocket.Chat Repository: RocketChat/Rocket.Chat.Electron#1251

@firlevapz
Copy link
Contributor Author

I've just created a PR for it, the proposed solution works for my setup but I'm not sure if it breaks something else: #19646

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants