Securrency-OSS / mirai

Mirai is a Server-Driven UI (SDUI) library for Flutter. Mirai allows you to build beautiful cross-platform applications with JSON in real time.
https://pub.dev/packages/mirai
MIT License
509 stars 61 forks source link

feat: Authorization token storage #50

Open RodolfoSilva opened 1 year ago

RodolfoSilva commented 1 year ago

Description

We need a way to persist and destroy the passkey on the device to allow apps that have authentication to be able to persist the passkey locally and avoid the user having to provide credentials again. Perhaps a simple encrypted key-value storage will solve this use case.

And also some way to always send this data in the request to the server, through the header perhaps.

Requirements

Additional Context

This will unlock advanced features when the app needs to keep some data locally to be used in future accesses.

Maybe it's just a feature to store a bearer token locally and send it every time the app requests something from the server.

i-asimkhan commented 1 year ago

Hey, @RodolfoSilva It's a great idea we have done an investigation and here is a detailed analysis of this issue.

In the context of Mirai (server-driven UI framework for Flutter), there are two main challenges, one is to authorize the right client to retrieve UI resources and the other is to pursue the right resource of user-specific data inside the user interfaces.

For instance, let's skip authorizing the accessibility of Mirai interface templates, then here is the list of challenges we have.

Now let’s discuss what are the possible ways in which we can achieve this functionality in Mirai.

After this detailed analysis, we have come up with this solution that we can use secure-storage of the key-values which is completely independent of the fact that we are going to use it for storing and retrieving authorization but it will provide Mirai with an added functionality of secure storage. What are your thoughts on this?

RodolfoSilva commented 1 year ago

I think if we add the ability to add new custom actions like we do with widgets, it gives more power to the user to decide how they want to use their local storage or something else. Mirai now supports receiving a Dio instance, this allows the user to implement their own authorization strategy and even invalidate the authorization.

But I think the main purpose of making this feature possible is to provide a way to register new custom actions like we did for widgets.