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

🐛 Bug Report: LinkedIn Oauth2 Broken #4827

Closed
2 tasks done
superseby2 opened this issue Dec 8, 2022 · 5 comments
Closed
2 tasks done

🐛 Bug Report: LinkedIn Oauth2 Broken #4827

superseby2 opened this issue Dec 8, 2022 · 5 comments
Assignees
Labels
bug Something isn't working product / auth Fixes and upgrades for the Appwrite Auth / Users / Teams services.

Comments

@superseby2
Copy link

👟 Reproduction steps

  • create an Oauth2Session like so appwrite.account.createOAuth2Session('linkedin',successPath,errorPath)
  • Linkedin prompts for credentials
  • On submit, Linkedin displays ""Bummer, something went wrong.
    We're having difficulty connecting."

We have opened an issue at LinkedIN here is their reply :

We see that in the URI the request has an encoded state parameter and redirectURI parameter. However the state parameter should be a unique string as recommended by https://www.rfc-editor.org/rfc/rfc6749#section-4.1.1. Please try double encoding the state parameter. Encoding the redirectURI can also cause issues.

Please review our documentation here https://learn.microsoft.com/en-us/linkedin/shared/authentication/authorization-code-flow?tabs=HTTPS

We dived a little bit our side and indeed if we urlencode the state parameter the pb goes away.
from src/Appwrite/Auth/OAuth2/Linkedin.php

  'https://www.linkedin.com/oauth/v2/authorization?' . \http_build_query([
            'response_type' => 'code',
            'client_id' => $this->appID,
            'redirect_uri' => $this->callback,
            'scope' => \implode(' ', $this->getScopes()),
            'state' => urlencode(\json_encode($this->state)),
        ]);

from 'app/controllers/api/account.phpinApp::get('/v1/account/sessions/oauth2/:provider/redirect')` line 363

$state = urldecode($state);

It seems lile LinkedIN urldecode his side and the state being only url-encoded once messes up somehow when decoded. (At least that is my understanding).
It might actually make sense to do this for every OAuth providers as "state" as defined by the RFC should be a String and nothing else.

Could you please have a look ?

👍 Expected behavior

  • When the login is successful the redirectURL should be called
  • The user should be loggedin

👎 Actual Behavior

  • Users see the LinkedIn Error Page
  • Users are not logged in into our app

🎲 Appwrite version

Version 0.14.x

💻 Operating system

Linux

🧱 Your Environment

No response

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

@superseby2 superseby2 added the bug Something isn't working label Dec 8, 2022
@stnguyen90
Copy link
Contributor

Thanks for raising this! 🙏🏼 We'll look into this as soon as we can!

@stnguyen90 stnguyen90 added the product / auth Fixes and upgrades for the Appwrite Auth / Users / Teams services. label Dec 8, 2022
@SoulPancake
Copy link

@stnguyen90 Can I work on this? Seems fairly straightforward as @superseby2 suggested, are there any additional caveats to this?

@stnguyen90
Copy link
Contributor

@SoulPancake there may be some other implications. Best to leave this with the core team.

@stnguyen90
Copy link
Contributor

So I just tested this on the latest version of Appwrite, but I wasn't able to reproduce the problem as the session created fine for me:

image

@superseby2, are you still experiencing this or may I close this issue?

@stnguyen90 stnguyen90 self-assigned this Jul 27, 2023
@gewenyu99
Copy link

@stnguyen90 I'm closing due to inactivity. Feel free to reopen if you found this issue, and have reproduction steps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working product / auth Fixes and upgrades for the Appwrite Auth / Users / Teams services.
Projects
None yet
Development

No branches or pull requests

4 participants