forked from retoor/devplacepy
Auth: username+password, email+password and API key everywhere; key returns carry username and email
POST /auth/login (form and JSON) now accepts the username in the email field, like HTTP Basic and POST /auth/token always did; the token endpoint no longer lowercases the identifier before the username lookup, fixing mixed-case usernames. The login field is relabelled and type=text so browsers accept a username.
Every JSON return of the personal API key now also returns the account username and email: the profile JSON gains a can_view_api_key-gated email beside api_key (username already rides profile_user), and POST /profile/regenerate-api-key returns {api_key, username, email}. A client holding only its DEVPLACE_API_KEY value can now fetch its full account via GET /profile in one call.
Documented fully: authentication prose page (three credentials, precedence, DEVPLACE_API_KEY, account fetch, separate DevRant/WebSocket auth domains), new auth-token docs_api card, regenerated-key sample, conventions, README, CLAUDE.md, OpenAPI description, corrected profile key hint. Summary in changes.md (left unversioned per request).
Tests: username/mixed-case/uppercase-email login and token cases, API-key account fetch via X-API-KEY and Bearer, owner/admin vs stranger/guest email gating, regenerate shape, browser login by username. Failing-first observed red, green after.
This commit is contained in:
@@ -204,6 +204,14 @@ def test_login_next_redirects_to_target(page, app_server, seeded_db):
|
||||
page.wait_for_url("**/gists", wait_until="domcontentloaded")
|
||||
|
||||
|
||||
def test_login_with_username(page, app_server, seeded_db):
|
||||
page.goto(f"{BASE_URL}/auth/login?next=/gists", wait_until="domcontentloaded")
|
||||
page.fill("#email", seeded_db["alice"]["username"])
|
||||
page.fill("#password", seeded_db["alice"]["password"])
|
||||
page.click("button:has-text('Sign in')")
|
||||
page.wait_for_url("**/gists", wait_until="domcontentloaded")
|
||||
|
||||
|
||||
def test_login_next_rejects_external(page, app_server, seeded_db):
|
||||
page.goto(
|
||||
f"{BASE_URL}/auth/login?next=https://evil.example.com",
|
||||
|
||||
Reference in New Issue
Block a user