Skip to content

Commit

Permalink
move auth config from static file to config map (#16)
Browse files Browse the repository at this point in the history
Plus some minor changes to UI

Co-authored-by: Sameer Kulkarni <[email protected]>
  • Loading branch information
samkulkarni20 and Sameer Kulkarni authored Aug 24, 2024
1 parent 386f9da commit 3ce47df
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ export USE_PORTKEY="0"
# Model specific options
export MODEL_ID="qwen/Qwen2-7B-Instruct"
export STOP_TOKEN="<|endoftext|>"

# Streamlit configurations
export AUTH_CONFIG_FILE_PATH=".streamlit/config.yaml"
export STREAMLIT_CLIENT_SHOW_ERROR_DETAILS=False
8 changes: 7 additions & 1 deletion .streamlit/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ credentials:
logged_in: false
name: Sanket Test
password: $2b$12$iWlVOac3uujRvTrXDi6wructXftKmo/GyQd6SMu5FmyX306kH.yFO
sameerk:
skulk3:
email: [email protected]
failed_login_attempts: 0
logged_in: false
name: Sameer Kulkarni
password: $2b$12$iWlVOac3uujRvTrXDi6wructXftKmo/GyQd6SMu5FmyX306kH.yFO
skulk4:
email: [email protected]
failed_login_attempts: 0
logged_in: false
Expand Down
52 changes: 52 additions & 0 deletions k8s-manifests/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
apiVersion: v1
data:
config.yaml: |-
cookie:
expiry_days: 30
key: some_signature_key
name: some_cookie_name
credentials:
usernames:
jdoe:
email: [email protected]
failed_login_attempts: 0
logged_in: false
name: John Doe
password: $2b$12$iWlVOac3uujRvTrXDi6wructXftKmo/GyQd6SMu5FmyX306kH.yFO
stest:
email: [email protected]
failed_login_attempts: 0
logged_in: false
name: Sanket Test
password: $2b$12$iWlVOac3uujRvTrXDi6wructXftKmo/GyQd6SMu5FmyX306kH.yFO
stest2:
email: [email protected]
failed_login_attempts: 0
logged_in: false
name: Sanket Test
password: $2b$12$iWlVOac3uujRvTrXDi6wructXftKmo/GyQd6SMu5FmyX306kH.yFO
skulk3:
email: [email protected]
failed_login_attempts: 0
logged_in: false
name: Sameer Kulkarni
password: $2b$12$iWlVOac3uujRvTrXDi6wructXftKmo/GyQd6SMu5FmyX306kH.yFO
skulk4:
email: [email protected]
failed_login_attempts: 0
logged_in: false
name: Sameer Kulkarni
password: $2b$12$iWlVOac3uujRvTrXDi6wructXftKmo/GyQd6SMu5FmyX306kH.yFO
amanj:
email: [email protected]
failed_login_attempts: 0
logged_in: false
name: Aman Juneja
password: $2b$12$iWlVOac3uujRvTrXDi6wructXftKmo/GyQd6SMu5FmyX306kH.yFO
pre-authorized:
emails:
- [email protected]
kind: ConfigMap
metadata:
creationTimestamp: null
name: insightful-auth-config
5 changes: 5 additions & 0 deletions k8s-manifests/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ spec:
readOnly: true
- name: empty
mountPath: /tmp/
- name: auth-config
mountPath: /opt/auth-config
dnsPolicy: ClusterFirst
nodeSelector:
kubernetes.io/hostname: infracloud02
Expand All @@ -71,5 +73,8 @@ spec:
secret:
defaultMode: 420
secretName: gh-pat
- name: auth-config
configMap:
name: insightful-auth-config
- name: empty
emptyDir: {}
4 changes: 4 additions & 0 deletions k8s-manifests/env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ data:
PORTKEY_CUSTOM_HOST: "llm_provider_host_ip_and_port"
USE_PORTKEY: "0"
USE_RERANKER: "1"
AUTH_CONFIG_FILE_PATH: "/opt/auth-config/config.yaml"
MODEL_ID: "meta-llama/Meta-Llama-3.1-8B-Instruct"
STOP_TOKEN: "<|endoftext|>"
STREAMLIT_CLIENT_SHOW_ERROR_DETAILS: False
8 changes: 6 additions & 2 deletions multi_tenant_rag.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
logging.basicConfig(format="%(asctime)s - %(message)s", level=logging.INFO)

def configure_authenticator():
with open(".streamlit/config.yaml") as file:
auth_config = os.getenv("AUTH_CONFIG_FILE_PATH", default=".streamlit/config.yaml")
print(f"auth_config: {auth_config}")
with open(file=auth_config) as file:
config = yaml.load(file, Loader=SafeLoader)

authenticator = stauth.Authenticate(
Expand All @@ -42,6 +44,7 @@ def authenticate(op):
name, authentication_status, username = authenticator.login()
st.session_state["authentication_status"] = authentication_status
st.session_state["username"] = username
st.session_state["name"] = name
elif op == "register":
try:
(
Expand Down Expand Up @@ -164,5 +167,6 @@ def main():
if __name__ == "__main__":
authenticator = authenticate("login")
if st.session_state["authentication_status"]:
authenticator.logout()
st.sidebar.text(f"Welcome {st.session_state['username']}")
authenticator.logout(location="sidebar")
main()

0 comments on commit 3ce47df

Please sign in to comment.