mkhorasani / Streamlit-Authenticator

A secure authentication module to validate user credentials in a Streamlit application.
Apache License 2.0
1.38k stars 229 forks source link

Feature - Store YAML file in a remote data store #42

Open abdulrabbani00 opened 1 year ago

abdulrabbani00 commented 1 year ago

It would be terrific is the user credentials could be stored in a remote data store (Deta, Mongo, etc).

I would be happy to integrate this feature if you are interested in having it incorporated.

abdulrabbani00 commented 1 year ago

I see a few solutions for this. But I think the simplest solution is:

  1. Utilize the config.yaml file for all config parameters, excluding the credentials.
  2. Within the config.yaml file, users can specify how they want the credentials stored:
    credential_store: "deta"
    ....
    credential_store: "config.yaml"
    ....
    credential_store: "credentials.yaml"
    ....
  3. We continue to store and access user credentials within the code as a dictionary. The only difference is, at load and at save, depending on the credential_Store option, we store or load the credentials with a specific adapter.
mkhorasani commented 1 year ago

Hi @abdulrabbani00, I will look into this for a future release. Many thanks.

VovaViliLox commented 1 year ago

Hello @mkhorasani @abdulrabbani00 , do you think it would be possible to add a flag that appends a remote data store like Deta only after a click in verification e-mail? Say, if someone were to send a registration request from example@preauthorized_domain.com, I would like to first send an expiring link to example@preauthorized_domain.com, and only after they click on a link in their e-mail I append their name.

Technically it is possible to do if this app were to be integrated with Firebase.

abdulrabbani00 commented 1 year ago

Yeah that makes sense. Although tbh I have no insensitive to do it.

If you opened a pr against my branch I would be more than happy to test and merge.

mkhorasani commented 1 year ago

@abdulrabbani00 @VovaViliLox apologies for the delay in investigating these PR's, will try to check/accept them very soon!

VovaViliLox commented 1 year ago

Yeah that makes sense. Although tbh I have no insensitive to do it.

If you opened a pr against my branch I would be more than happy to test and merge.

Yes, once I'll figure it out I for sure will open a pull request.

iuiu34 commented 8 months ago

any update on this?

elmighetto commented 4 months ago

do you think it would be possible to add a flag that appends a remote data store like Deta only after a click in verification e-mail? Say, if someone were to send a registration request from example@preauthorized_domain.com, I would like to first send an expiring link to example@preauthorized_domain.com, and only after they click on a link in their e-mail I append their name.

I've implemented something similar for my app. I hold off on writing the 'create account' updated config until the user inputs a random key sent to their email using yagmail. Once they enter it, then I write their updated user config to the remote storage so the account is actually created. Using remote storage is accomplished fairly simply by just reading and writing from a remote file instead of a local file using st_files_connection.

I think adding a note to the readme that writing the local config.yaml file does not work well when hosted on the streamlit community cloud, and a remote file system will need to be used to support account creation would be a good addition.

drankush commented 2 months ago

@elmighetto , can you suggest what/where are you using for hosting your remote file and you are storing it as yaml or in db. Also you mean, once the user enters that random key, it creates credentials directly into the config.yaml on the remote file?

I will appreciate some clarity as Im trying to achieve the same.