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

Groups #64

Closed Feromond closed 5 months ago

Feromond commented 1 year ago

I created a generally functioning group system that can be accessed by users to manage permissions later on.

Two new methods were added to the Authenticator class which are "change_group" & "_change_group_credentials()". There was also a modification made to the "_register_credentials" method so that upon user registration, they are also assigned to the "default" group.

The idea behind this addition is that the user groups will be added to the config.yaml credentials, and can be accessed in the future by developers to generate conditional access based on being part of a select group or multiple groups. The change group method can then be used to have a front-end means of editing user groups, as well as creating new groups.

Currently, the behavior of these groups is that at least one user must be assigned to a group for it to exist. If a group existed but all users are changed to alternative groups, that previous group will be removed from the list of options. This could be rectified in a future change but I don't think of it as a very significant issue right now.

The code for building the change_group front end is a bit messy right now due to the strange behavior of the form_submit_button in Streamlit. I would spend more time to clean things up in the future but due to my currently limited time, I just wanted to get some feedback on the overall PR before I would continue any further on these changes.

Let me know if this concept makes sense and I will find time to make revisions over the coming few weeks if desired.

mkhorasani commented 5 months ago

Hi @Feromond, I recommend you simply add a new field to the credentials dictionary in the config file to accommodate this request without refactoring the library itself. There are multiple requests of similar nature so it would only make sense if each developer took it upon themselves to add a new field to the config file as they see fit. Thank you.