Take auth/ whole from boilerplate 09e144d: the lockout claimed before the scrypt, APP_PASSWORD recovery closing every session, Starlette's cookie parser, the rightmost forwarded hop in the log, revoke_all on a password change, a 421 for a non-loopback Host on an open app, API tokens in auth_tokens behind Authorization: Bearer, and sockets closed with their credential
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
83e965dfeb
commit
244e57ac29
19 files changed
+2288
-214
No files matched your search
+25
-2
@@ -1,8 +1,8 @@
|
||||
"""What the Account tab is told, and nothing more.
|
||||
|
||||
Three models, and the thing worth noticing about all three is what they cannot
|
||||
Four models, and the thing worth noticing about all four is what they cannot
|
||||
carry. No token, no hash, no key material — not even the public half of a
|
||||
passkey. The list of ways into an app is the one page most worth reading and
|
||||
passkey; of an API token, the first eight characters and never the rest. The list of ways into an app is the one page most worth reading and
|
||||
least worth leaking, so the shape it is rendered from is one that could not
|
||||
leak a credential if it were logged whole.
|
||||
"""
|
||||
@@ -47,6 +47,27 @@ class Passkey(BaseModel):
|
||||
transports: list[str] = Field(default_factory=list)
|
||||
|
||||
|
||||
class ApiToken(BaseModel):
|
||||
"""One token a script signs in with, as the account screen sees it.
|
||||
|
||||
The token itself is shown once, when it is made (`TokenCreated` in
|
||||
`auth/schemas.py`), and is not here: this is the row, which is what the
|
||||
revoke button sends back. `hint` is the token's opening, enough to match
|
||||
the row to the environment variable that holds the whole.
|
||||
"""
|
||||
|
||||
id: int
|
||||
#: What you called it. Named for the machine or the job that holds it, so
|
||||
#: the one to revoke can be told from the others.
|
||||
label: str = ""
|
||||
#: The token's first characters. See `auth.store.HINT`.
|
||||
hint: str = ""
|
||||
created_at: str = ""
|
||||
last_used_at: str = ""
|
||||
#: When it stops working, or "" for a token that does not expire.
|
||||
expires_at: str = ""
|
||||
|
||||
|
||||
class Account(BaseModel):
|
||||
"""What the account screen knows. Deliberately almost nothing.
|
||||
|
||||
@@ -79,3 +100,5 @@ class Account(BaseModel):
|
||||
#: honest common case is an insecure origin: WebAuthn refuses anything but
|
||||
#: HTTPS, localhost excepted, so this reads "you need TLS first".
|
||||
passkeys_blocked: str = ""
|
||||
#: The API tokens, expired ones included, each without its secret.
|
||||
tokens: list[ApiToken] = Field(default_factory=list)
|
||||
Reference in new issue
Block a user