gibahjoe / keycloak_flutter

Keycloak package for easy integration with flutter applications
BSD 3-Clause "New" or "Revised" License
24 stars 24 forks source link

URL strategy clarification #4

Closed jonasbark closed 3 years ago

jonasbark commented 3 years ago

Hi there!

The readme mentions

The configureUrlStrategy() above uses a custom implementation of the PathUrlStrategy which cleans out your url to be more like a regular web application url. This is required for keycloak to work properly. More info here

yet it seems to work just fine without this. Can you clarify why it is deemed required?

gibahjoe commented 3 years ago

Hi, usually, flutter web urls have a # (url fragment) in it which causes a clash with keycloak because keycloak uses same url fragment to persist state information . So, when keycloak passes the state fragment, flutter will see it as a url and try to parse it as one there by leading to route not found error or sometimes keycloak is not able to process or persist the state information.

configureUrlStrategy() tried to circumvent this by removing the # in the url so instead of your url looking like www.domain.com/#/home it looks like www.domain.com/home then keycloak can add its state information like `www.domain.com/home#state=1234&session=12345

Now, this was the case with the last version of flutter beta, but i haven't had the time to look at it since the new version was released. I will take a look at it today for sure.

Are you able to use keycloak just fine without the url strategy? what flutter version do you use?

jonasbark commented 3 years ago

Thanks for the explanation - I'll keep this in mind.

This is the how the URL looks after logging in: https://.../subdirectory/#state=...&session_state=...&code=... And after keycloak-js extracts the information: https://app.propops.com/dev/dashboard-flutter/#/

Seems to work fine.

I'm using dev 1.26.0-17.1.pre.