New front-end Launch Chat API Manage Sources Enable re-embedding of all contents Sources can be added without a notebook now Improved settings Enable model selector on all chats Background processing for better experience Dark mode Improved Notes Improved Docs: - Remove all Streamlit references from documentation - Update deployment guides with React frontend setup - Fix Docker environment variables format (SURREAL_URL, SURREAL_PASSWORD) - Update docker image tag from :latest to :v1-latest - Change navigation references (Settings → Models to just Models) - Update development setup to include frontend npm commands - Add MIGRATION.md guide for users upgrading from Streamlit - Update quick-start guide with correct environment variables - Add port 5055 documentation for API access - Update project structure to reflect frontend/ directory - Remove outdated source-chat documentation files
53 lines
No EOL
1.6 KiB
Python
53 lines
No EOL
1.6 KiB
Python
import os
|
|
|
|
import streamlit as st
|
|
|
|
|
|
def check_password():
|
|
"""
|
|
Check if the user has entered the correct password.
|
|
Returns True if authenticated or no password is set.
|
|
"""
|
|
# Get the password from environment variable
|
|
app_password = os.environ.get("OPEN_NOTEBOOK_PASSWORD")
|
|
|
|
# If no password is set, skip authentication
|
|
if not app_password:
|
|
return True
|
|
|
|
# Check if already authenticated in this session
|
|
if "authenticated" in st.session_state and st.session_state.authenticated:
|
|
return True
|
|
|
|
# Show login form
|
|
with st.container():
|
|
st.markdown("### 🔒 Authentication Required")
|
|
st.markdown("This Open Notebook instance is password protected.")
|
|
|
|
with st.form("login_form"):
|
|
password = st.text_input(
|
|
"Password",
|
|
type="password",
|
|
placeholder="Enter password"
|
|
)
|
|
submitted = st.form_submit_button("Login")
|
|
|
|
if submitted:
|
|
if password == app_password:
|
|
st.session_state.authenticated = True
|
|
st.success("Successfully authenticated!")
|
|
st.rerun()
|
|
else:
|
|
st.error("Incorrect password. Please try again.")
|
|
|
|
# Stop execution if not authenticated
|
|
if "authenticated" not in st.session_state or not st.session_state.authenticated:
|
|
st.stop()
|
|
|
|
return True
|
|
|
|
|
|
def logout():
|
|
"""Clear authentication from session state."""
|
|
if "authenticated" in st.session_state:
|
|
del st.session_state.authenticated |