Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add API_KEY list support #877

Merged
merged 6 commits into from Aug 9, 2023
Merged

feat: add API_KEY list support #877

merged 6 commits into from Aug 9, 2023

Conversation

neboman11
Copy link
Contributor

Description

This PR fixes #729 and #480

This PR is a copy of #740 but with the API key option changed to a list (as requested in that PR).

This PR adds api-key flag. When this flag is set, all API requests needs to provide the same value as Bear token in the request hear. If this flag is not set, no auth will be enabled. This flag is not set by default.

Notes for Reviewers

Signed commits

  • Yes, I signed my commits.

main.go Outdated Show resolved Hide resolved
@neboman11 neboman11 requested a review from mudler August 9, 2023 20:49
@mudler mudler changed the title Add API_KEY list support feat: add API_KEY list support Aug 9, 2023
Copy link
Owner

@mudler mudler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good here, thanks!

@mudler mudler merged commit 1d1cae8 into mudler:master Aug 9, 2023
8 checks passed
@mudler mudler mentioned this pull request Aug 9, 2023
@mudler mudler added the enhancement New feature or request label Aug 9, 2023
@neboman11 neboman11 mentioned this pull request Aug 10, 2023
1 task
@luisfarzati
Copy link

@neboman11 you rock ❤️ thank you!

@alexander-potemkin
Copy link

I'm sorry, and how does it work with models/available endpoint?

I'm having problems checking for the models available:

# curl http://localhost:8080/models/available -H "Authorization: Bearer $myApiKey"
{"message":"Invalid API key"}

@alexander-potemkin
Copy link

btw, same when I try to query the model, by using default's OpenAI's example:

curl http://localhost:8080/v1/chat/completions   -H "Content-Type: application/json"   -H "Authorization: Bearer $myApiKey"   -d '{
    "model": "gpt-3.5-turbo",
    "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."
      }
    ]
  }'
{"message":"Invalid API key"}

@alexander-potemkin
Copy link

Please, forgive me - I shouldn't been adding quotes for the key in my docker-compose.yml.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Protect endpoints with an API key
5 participants