timmy / 使用 Streamlit 建立使用者身份驗證系統
0 likes
0 forks
2 files
Last active 10 months ago
這段程式碼使用 Streamlit 和 streamlit-authenticator 來 管理使用者登入,透過 YAML 設定檔 儲存使用者憑證與 Cookie 配置,並提供 登入、登出 和 使用者驗證 功能。
| 1 | cookie: |
| 2 | expiry_days: 30 |
| 3 | key: some_signature_key |
| 4 | name: my_auth_cookie |
| 5 | credentials: |
| 6 | usernames: |
| 7 | jsmith: |
| 8 | email: jsmith@gmail.com |
| 9 | failed_login_attempts: 0 # Will be managed automatically |
| 10 | logged_in: False # Will be managed automatically |
timmy / 使用 Streamlit 建立簡單使用者驗證系統
0 likes
0 forks
1 files
Last active 10 months ago
這段程式碼使用 streamlit_authenticator 建立一個簡單的登入系統,支持使用者驗證(帳號、密碼)和登出功能,並在側邊欄提供登出按鈕。密碼經過雜湊處理以增加安全性。
| 1 | import streamlit as st # 匯入 streamlit 模組 |
| 2 | import streamlit_authenticator as stauth # 匯入 streamlit_authenticator 模組 |
| 3 | |
| 4 | names = ["John", "Mary"] # 定義名字清單 |
| 5 | usernames = ["john", "mary"] # 定義使用者名清單 |
| 6 | passwords = ["1234", "5678"] # 定義密碼清單 |
| 7 | |
| 8 | hashed_passwords = stauth.Hasher(passwords).generate() # 使用 Hasher 類別對密碼進行雜湊處理 |
| 9 | |
| 10 | authenticator = stauth.Authenticate( # 建立一個 stauth.Authenticate 的實例 authenticator |
timmy / MySQL 設定 root 使用者權限與密碼
0 likes
0 forks
1 files
Last active 10 months ago
這段 MySQL 指令 用於 建立 root 帳戶並賦予全域權限,適用於 開放遠端連線的 MySQL 伺服器。
| 1 | CREATE USER 'root'@'%' IDENTIFIED BY 'my_root_pwd'; |
| 2 | GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'; |
| 3 | FLUSH PRIVILEGES; -- 重新整理權限表 |
| 4 | |
| 5 | ALTER USER 'root'@'%' IDENTIFIED BY 'my_root_pwd'; |
| 6 | FLUSH PRIVILEGES; -- 重新整理權限表 |
Newer
Older