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: # in URL causes parser to ignore ? #132

Closed
ynunez opened this issue Jan 22, 2021 · 1 comment
Closed

Bug: # in URL causes parser to ignore ? #132

ynunez opened this issue Jan 22, 2021 · 1 comment
Labels
bug Something isn't working web
Milestone

Comments

@ynunez
Copy link
Contributor

ynunez commented Jan 22, 2021

Capacitor version:

You can use npx cap doctor for the output from the root directory of your project. -->

Run npx cap doctor:

Latest Dependencies:

  @capacitor/cli: 2.4.6
  @capacitor/core: 2.4.6
  @capacitor/android: 2.4.6
  @capacitor/electron: 2.4.6
  @capacitor/ios: 2.4.6

Installed Dependencies:

  @capacitor/cli 2.4.6
  @capacitor/android 2.4.6
  @capacitor/core 2.4.6
  @capacitor/ios 2.4.6
  @capacitor/electron not installed

Library version:

  • 2.1.0

OAuth Provider:

  • Other: Custom

Your Plugin Configuration

            {
                appId: 'com.digiphan.apps.eznet',
                pkceEnabled: true,
                authorizationBaseUrl: `${environment.portal.accounts}auth/${social ? social : 'login'}`,
                accessTokenEndpoint: `${environment.api.security}auth/token/access`,
                scope: "ez",
                responseType: "code",
                web: {
                    redirectUrl: `${environment.portal.accounts}`,
                    windowOptions: "height=600,width=600,left=0,top=0"
                },
                android: {
                    redirectUrl: "digiphan:/"
                },
                ios: {
                    redirectUrl: "digiphan:/"
                }
            }

Affected Platform(s):

  • Web

Current Behavior

When the redirect URL contains a hash after the query params it fails to parse the parameters.

For example:

https://www.digiphan.com/auth/verify?client_id=com.digiphan.apps.eznet&response_type=code&scope=ez&state=QMVxtar1wd3EgsV7Z0UA&code_challenge=8VuJBHHnDdGtIZTA8AysVuwktmt7taZdNnw-eL8KrOU&code_challenge_method=S256&code=AUTH_CODE_HERE#_=_

Expected Behavior

It should parse the parameters after the ? and ignore the # if it's after.

Parameters should be parsed as follows for the url above

client_id=com.digiphan.apps.eznet
response_type=code
scope=ez
state=QMVxtar1wd3EgsV7Z0UA
code_challenge=8VuJBHHnDdGtIZTA8AysVuwktmt7taZdNnw-eL8KrOU
code_challenge_method=S256
code=AUTH_CODE_HERE

Reproduction Steps

It can be reproduced if the redirect url contains a hash (#) after the query params indicator (?). Below is the snippet of code that is causing it (web-utils.ts ). As you see it ignores ? if it contains a #

let idx = urlString.indexOf("#");
if (idx === -1) {
    idx = urlString.indexOf("?");
}
ynunez added a commit to ynunez/capacitor-oauth2 that referenced this issue Jan 22, 2021
ynunez added a commit to ynunez/capacitor-oauth2 that referenced this issue Jan 22, 2021
@moberwasserlechner moberwasserlechner added bug Something isn't working web labels Jul 1, 2021
@moberwasserlechner moberwasserlechner added this to the 3.0.0 milestone Jul 1, 2021
@moberwasserlechner
Copy link
Collaborator

Thanks for the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working web
Projects
None yet
Development

No branches or pull requests

2 participants