Onboarding, login, signIn flow #151
-
Hello, I'm considering some modern approaches for rewrite an old style app to KMM. I'm interested in few things particularly - deep links, onboarding and authentication across screens. I saw that there is documentation about the deep links (thanks for that) but can someone give me some guidelines, some pseudo code, sample or something about what should be the proper way implementing authentication with Decompose? Other kits and libraries I saw, enforce to check on each screen and preserve the login state with a flag or something. Is there a central way let's say via the router aka. child stack? Is Decompose flexible enough to handle session expiration for example? All kinds of information are more than welcome! Thanks! 🙏 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 10 replies
-
Hello and thanks for the question! After quickly searching through GitHub, I found Lastik app which seems to have an auth feature. But I didn't deep dive into the implementation details. Maybe other folks could provide their examples?
I believe there couldn't be any single "proper" way of handling authentication. Decompose is very flexible and different developers may come up with different ideas specific for their projects.
The first idea is to utilize Custom ComponentContext. You could create some sort of Overall, this highly depends on the exact requirements of your project. Maybe you could describe in more details what screens do you have and what is the logic behind handling the authentication? |
Beta Was this translation helpful? Give feedback.
-
I am working on a similar project and the first thing I started with was the authentication. Since I wanted to integrate OAuth 2.0 with OIDC my structure looks as follow (registration and authenticated routes are not implemented yet). In the example structure the components My implementation uses Ktor (HttpClient) for getting the access token and passes it upwards once authenticated, so that I can get into the The onboarding you mentioned could be either part of the authenticated components or separate components, depending on how the onboarding will work / displayed. But I think separating them completely is a good idea in general, so that you follow the separation of concerns principle. And about session / token expiration: I still haven't implemented that, but the clients I use support middlewares. If those are not enough I would probably try somehow to publish a label so that another component (like the |
Beta Was this translation helpful? Give feedback.
I am working on a similar project and the first thing I started with was the authentication.
Since I wanted to integrate OAuth 2.0 with OIDC my structure looks as follow (registration and authenticated routes are not implemented yet).
In the example structure the components
Root
,Unauthenticated
,Authenticated
andAuth
(which is the login) hold their ownChildStack
.Auth
->Main
is the basic username and password authentication,DeviceCode
is a flow that was a proof of concept and will be removed, andGoogle
is the authentication flow with an identity provider (here limited to Google only).My implementation uses Ktor (HttpClient) for getting the access token and passes it upwards once aut…