riazmo Claude Opus 4.6 commited on
Commit
412b593
·
1 Parent(s): 37d8fe2

security: stop exposing HF token in public UI

Browse files

- Never pre-fill the token textbox with env variable value
- Show 'Token loaded from environment' as placeholder instead
- Internal inference still uses the env token

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -4503,11 +4503,11 @@ def create_ui():
4503
  elem_classes=["section-desc"])
4504
  with gr.Row():
4505
  hf_token_input = gr.Textbox(
4506
- label="HF Token", placeholder="hf_xxxx", type="password",
4507
- scale=4, value=HF_TOKEN_FROM_ENV,
4508
  )
4509
  save_token_btn = gr.Button("💾 Save", scale=1)
4510
- token_status = gr.Markdown("✅ Token loaded" if HF_TOKEN_FROM_ENV else "⏳ Enter token")
4511
 
4512
  def save_token(token):
4513
  if token and len(token) > 10:
 
4503
  elem_classes=["section-desc"])
4504
  with gr.Row():
4505
  hf_token_input = gr.Textbox(
4506
+ label="HF Token", placeholder="hf_xxxx" if not HF_TOKEN_FROM_ENV else "Token loaded from environment",
4507
+ type="password", scale=4, value="",
4508
  )
4509
  save_token_btn = gr.Button("💾 Save", scale=1)
4510
+ token_status = gr.Markdown("✅ Token loaded from environment" if HF_TOKEN_FROM_ENV else "⏳ Enter token")
4511
 
4512
  def save_token(token):
4513
  if token and len(token) > 10: