express-gateway icon indicating copy to clipboard operation
express-gateway copied to clipboard

Application redirect_uri can't be redirect if # character is included in the url (Single Page Application #-url)

Open herbertsg opened this issue 8 years ago • 5 comments

Hello, i'm implementing a javascript application with Vue (SPA), but i have the following problem with the application redirect_uri. The redirect_uri is set in the application as: 'http://localhost/#/welcome'

{ "name": "rosarioapp", "redirectUri": "http://localhost/#/welcome", "isActive": true, "id": "f946933b-811e-4f38-9ea5-d0bd07b66c27", "userId": "9797f256-f861-4eca-854e-5e9c33efd41d", "createdAt": "Wed Mar 07 2018 14:50:57 GMT+0000 (UTC)", "updatedAt": "Mon Mar 19 2018 22:18:02 GMT+0000 (UTC)" }

When the authorization endpoint is executed: http://localhost:8080/oauth2/authorize?response_type=token&client_id=f946933b-811e-4f38-9ea5-d0bd07b66c27&redirect_uri=http://localhost/#/welcome an AuthorizationError: Unauthorized client is returned.

Note the hash in the url if i remove the hash, the page is redirected to the login page as expected but after the login, of course it is not redirected to my page: http://localhost/#/welcome.

I think that there's a problem with the redirect_uri that include a url like this http://localhost/#/welcome that include a hash.

herbertsg avatar Mar 20 '18 03:03 herbertsg

possible bug that might need verification

altsang avatar Mar 27 '18 16:03 altsang

This is my test application: testOAuth.zip

To execute: npm install npm run dev

Expected Gateway installation: http://localhost:8080

SPA application available in: http://localhost

Login url in src/js/views/Home.vue window.location.href = "http://localhost:8080/oauth2/authorize?response_type=token&client_id=f946933b-811e-4f38-9ea5-d0bd07b66c27&redirect_uri=http://localhost/#/welcome";

herbertsg avatar Apr 02 '18 18:04 herbertsg

Thanks a lot for that! I'll be looking at this during this week.

XVincentX avatar Apr 04 '18 07:04 XVincentX

@herbertsg

This is not an Express Gateway bug.

URI Fragments never get sent to the server — they persist to the client.

Basically if you type https://myapp.com/#/home the server will only see https://myapp.com/.

You should be able to solve this problem by simply modifying the redirectUri attribute so that Express Gateway can correctly match the URI.

If you need any more assistance, feel free to repone the issue or stop by our Gitter channel.

Cheers!

XVincentX avatar Apr 10 '18 13:04 XVincentX

Thank you i resolved it using the history mode in the vue-router to avoid the hash use.

herbertsg avatar Jul 02 '18 21:07 herbertsg