Skip to content

Don't recreate the credentials dictionary #238

@traverseda

Description

@traverseda

You can get steamlit-authenticator to automatically save user accounts using a construct like this:

credential_store = {'usernames':shelve.open("./user_accounts.shelve")}

authenticator = stauth.Authenticate(
        credentials=credential_store,
)

This pairs even better with tools like zict

storage = zict.File(directory="./accounts")
utf8_to_bytes = zict.Func(lambda x: x.encode('utf8'), lambda x: x.decode('utf8'), storage)
encoder = zict.Func(yaml.safe_dump, yaml.safe_load, utf8_to_bytes)
credential_store = {'usernames':encoder}

Which will create a new yaml file for each user. You can also use sqlite, or lmdb, or even postgres transports.

But none of that works because instead of taking the actual credentials object at face value you recreate it using a standard python dict.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions