-
Notifications
You must be signed in to change notification settings - Fork 267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using the Authenticator with credentials stored in a remote database #193
Comments
Thank you for the prompt reponse. I kind of put together some skeleton code for a login page. It does not throw any error, but I see that, the execution seems to be stopping at Below is the full code for the page
|
Incredible package, so appreciated. Associated with this would be the ability to send email/username input and hashed password input to the authenticator. That way I can call remote db to retrieve a single user with one hashed password for the authenticator to match against instead of a big payload of all users That or allow the authenticator to give us the email input to make a small payload db call before matching passwords? |
This is in the pipeline and I hope to release it in Q4 of this year. Please stay tuned! |
Awesome. And if the ability is there to debundle username/email and password inputs from the authenticator so they can be sent as inputs to a non-render version of it, that allows us to use OAuth for authentication then use your authenticator to handle setting the cookies and session states |
Yeap, I will consider serving the logic as a service running on a backend server that the user can interface with. |
I don't know if this is relevant to the discussion, but I use Supabase as a remote DB to hold my authenticator credentials. I can't quite email a username/password to it, but I can edit the table by hand (which is really just a row holding the JSON) and add a user if I want. |
Thank you very much for this great library! |
@felipecordero Can you maybe make a pull request of your implementation? Or put a link here, so that others can use it as well. Thanks |
Hi @morphpiece and thank you for your patience :) My code is somehow very specific, so I think a pull request could be not fitting everyone approach. But here there is a piece of code from what I implemented: (Also, feel free to explore the firebase_admin documentation: https://firebase.google.com/docs/admin/setup?hl=en#python) import firebase_admin
import streamlit_authenticator as stauth
from firebase_admin import credentials, firestore
# Initialize Firebase
if not firebase_admin._apps:
cred = credentials.Certificate(st.secrets["db_name"].to_dict())
firebase_admin.initialize_app(cred)
# Starting communication with the firebase db
db = firestore.client()
# Here I read my collection with credentials
cred_ref = db.collection('credentials')
creds = cred_ref.stream()
config = {}
for doc in creds:
doc_dict = doc.to_dict()
config[doc.id] = doc_dict
config = config["credentials"]
# Pre-hashing all plain text passwords once
stauth.Hasher.hash_passwords(config['credentials'])
# sample code for saving new credentials
def write_credentials_config_firestore(db: firestore.client, config: dict):
main_collection = db.collection("credentials")
main_collection_doc_ref = main_collection.document("credentials")
main_collection_doc_ref.set(config) |
Hi - Can we use the Authenticator when credentials are stored in a remote database?
P.S - Did not find a place to post question, hence posting as an issue. Sorry if that is not per guidelines.
The text was updated successfully, but these errors were encountered: