CI / test (push) Successful in 1m9s
Every key needed an operator with a shell. This adds the login system that made that necessary, which is the thing I argued against building until it was asked for — so it is built as if it will be attacked, because a public login form is. Signing up produces an account that can do nothing. Approval is what makes it work and stays on the CLI: having a shell on the control plane is what makes someone an administrator, and that is a smaller thing to get right than roles and an admin UI that mints credentials. The details that matter: Passwords are argon2id, where a slow hash is correct — the input is chosen by a human and has a dictionary, which is the opposite of an API key. Both kinds of authentication now live in this codebase and they are in separate packages so neither set of assumptions leaks into the other. Length is the only rule: composition rules push people towards Password1! and cost more entropy than they buy. Signup never says whether an address already has an account, and sign-in answers the same way for a wrong password and a missing account — verifying against a dummy hash when there is no user, so a stopwatch cannot enumerate accounts. Account state is checked after the password, not before, so guessing an address reveals nothing about it. Guessing is bounded per address rather than per IP: an attacker has many addresses to come from and one to guess against, and limiting by IP locks out an office behind one NAT. Sessions are server-side, so signing out and suspending take effect immediately rather than whenever a token expires; suspension is checked in the same query that resolves the session, because a second round trip is a check somebody eventually forgets. Every state-changing form carries a CSRF token verified against a hash in the session — a cookie authenticates the browser, not the page that asked. Key ownership is enforced in the UPDATE rather than by reading first, so a guessed key id from another account changes nothing. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
64 lines
2.5 KiB
HTML
64 lines
2.5 KiB
HTML
{{define "landing"}}<!doctype html>
|
|
<html lang="en"><head>
|
|
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
|
<title>llmgw</title><link rel="stylesheet" href="/_static/base.css">
|
|
</head><body><div class="wrap">
|
|
<header>
|
|
<h1>llmgw</h1>
|
|
<p class="sub">An OpenAI-compatible endpoint in front of self-hosted models.</p>
|
|
</header>
|
|
|
|
<p>Point any OpenAI client at this address. The API is the one you already have a
|
|
client for; only the base URL changes.</p>
|
|
|
|
<h2>Base URL</h2>
|
|
<pre>{{.BaseURL}}/v1</pre>
|
|
|
|
<h2>Example</h2>
|
|
<pre>curl {{.BaseURL}}/v1/chat/completions \
|
|
-H "Authorization: Bearer $LLMGW_API_KEY" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{"model": "MODEL", "messages": [{"role":"user","content":"hello"}]}'</pre>
|
|
|
|
<pre>from openai import OpenAI
|
|
client = OpenAI(base_url="{{.BaseURL}}/v1", api_key=os.environ["LLMGW_API_KEY"])</pre>
|
|
|
|
<h2>Which models</h2>
|
|
{{if .AuthEnabled}}
|
|
<p><code>GET /v1/models</code> lists what is available to your key. It needs the key,
|
|
which is why this page does not list them: this page is served to anyone who can
|
|
reach the address.</p>
|
|
{{else}}
|
|
<p><code>GET /v1/models</code> lists what is available.</p>
|
|
<p class="note">This gateway has no API keys configured, so it serves anyone who can
|
|
reach it. That is a deployment choice and only safe on a trusted network.</p>
|
|
{{end}}
|
|
|
|
<h2>Getting a key</h2>
|
|
{{if .SignupOpen}}
|
|
<p><a href="/signup">Create an account</a>. Someone will approve it, and then you
|
|
can issue your own keys from your <a href="/profile">profile</a> — as many as you
|
|
need, revoking them yourself when a laptop is retired or a script is done.</p>
|
|
<p class="note">Already have an account? <a href="/login">Sign in</a>.</p>
|
|
{{else if .Contact}}
|
|
<p>Ask {{if .ContactHref}}<a href="{{.ContactHref}}">{{.Contact}}</a>{{else}}<strong>{{.Contact}}</strong>{{end}}
|
|
for one. {{if .AuthEnabled}}If you already have an account,
|
|
<a href="/login">sign in</a>.{{end}}</p>
|
|
{{else}}
|
|
<p>Keys are issued by whoever operates this gateway. If you do not know who that
|
|
is, the address you reached this page at is the place to start asking.</p>
|
|
{{end}}
|
|
<p>A key is shown once and never again — only its hash is kept here — so put it in
|
|
a password manager straight away.</p>
|
|
|
|
{{if .Notice}}<p class="note">{{.Notice}}</p>{{end}}
|
|
|
|
<h2>Once you have one</h2>
|
|
<ul>
|
|
<li><code>GET {{.BaseURL}}/v1/models</code> — what your key may use</li>
|
|
<li><code>GET {{.BaseURL}}/me</code> — its limits, and what it has spent</li>
|
|
</ul>
|
|
|
|
<footer><span>llmgw {{.Version}}</span><span>{{.Now}}</span></footer>
|
|
</div></body></html>{{end}}
|