zylon-ai / private-gpt

Interact with your documents using the power of GPT, 100% privately, no data leaks
https://privategpt.dev
Apache License 2.0
53.75k stars 7.22k forks source link

User Auth feature #1899

Open BBjie opened 5 months ago

BBjie commented 5 months ago

I have seen they are auth.py file and auth settings in settings.yaml file, I'm assuming the auth feature is enabled in this project. Is there any guidance/documentation I can refer to to achieve it?

setting.yaml

server:
  env_name: ${APP_ENV:prod}
  port: ${PORT:8001}
  cors:
    enabled: false
    allow_origins: ["*"]
    allow_methods: ["*"]
    allow_headers: ["*"]
  auth:
    enabled: true
    # python -c 'import base64; print("Basic " + base64.b64encode("secret:key".encode()).decode())'
    # 'secret' is the username and 'key' is the password for basic auth by default
    # If the auth is enabled, this value must be set in the "Authorization" header of the request.
    secret: "Basic c2VjcmV0OmtleQ=="
Kraego commented 4 months ago

Same question here

vk4hdi commented 3 months ago

Any one knew how this works, I have spent hours to work on this, still couldn't figure out how to have a simple password on the UI.

jaluma commented 2 months ago

I will try to explain how it works by default. Once you enable auth.enable=True, the system validates if a basic authentication is included. By default the Authorization header is: Authorization: Basic c2VjcmV0OmtleQ==. I attach an example using cURL:

curl http://localhost:8001/v1/chat/completions
-H "Content-Type: application/json" 
-H "Authorization: Basic c2VjcmV0OmtleQ=="
-d '{
    "messages": [
      {
        "role": "system",
        "content": "You are a poetic assistant, skilled in explaining complex programming concepts with creative flair."
      },
      {
        "role": "user",
        "content": "Compose a poem that explains the concept of recursion in programming."
      }
    ]
  }'
vk4hdi commented 2 months ago

Hi Jaluma

Thanks for the reply, however we want to have the authentication on the web interface, when a user typed: http://localhost:8081/ a authentication will pop up.

Thanks

phimue1 commented 1 week ago

Did you find a solution meanwhile? Facing the same problem...

jaluma commented 1 week ago

I reopened the issue and convert it to improvement. Currently, we consider gradio as testing ui, not the final one. Please consider use other alternatives or define a custom version yourself. In documentation, we have a react application without this issue: https://docs.privategpt.dev/manual/user-interface/alternatives