Validate the username and email against every system they are projected into #151
Etiketter
Inga etiketter
area/backups
area/ci
area/control-panel
area/identity
area/infra
area/observability
area/payments
area/security
area/storage
area/web
blocked
needs-info
needs-triage
ready-for-implementation
type
bug
type
chore
type
docs
type
epic
type
feature
type
task
wontfix
Ingen milstolpe
Inget projekt
Inga tilldelade
1 deltagare
Notiser
Förfallodatum
Inget förfallodatum satt.
Beroenden
Inga beroenden satta
Referens
bitborg/bitborg-web#151
Läser in…
Hänvisa till i nytt ärende
Ingen beskrivning angiven.
Ta bort grenen "%!s()"
Borttagning av en gren är permanent. Även om den borttagna grenen kan fortsätta existera en kort tid innan den faktiskt tas bort, kan det INTE ångras i de flesta fall. Vill du fortsätta?
The sign-up endpoint validates the username with
/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,39}$/and theemail with
/^[^\s@]+@[^\s@]+\.[^\s@]+$/. Both comments say the identity provider is "the finalauthority on validity", but neither rule matches its rules, and neither encodes the git host's
rules at all.
A value that the portal accepts can therefore be rejected downstream. The worst case is silent:
the identity provider accepts the name, the account is created, the set-up email is sent, the
password is set — and then the first sign-in to the git host fails with a 500, because the name is
reserved there. Nothing is shown to the user and nothing is logged.
Examples that pass sign-up today and produce an unusable account:
alice.,bob-,a--b,foo..barapi,explore,metrics,user,repo,org,issues,pulls,notifications,ghost,robots.txt,sitemap.xml,favicon.icoalice.keys,alice.png,alice.rssExamples that fail at the identity provider with an unexplained "check your details":
7aliceanvändare@example.se— likely on a Swedish serviceAnd one that succeeds while diverging: an uppercase username is silently lower-cased by the
identity provider, so the consent record we write (keyed on the submitted spelling) no longer
matches the account that exists.
What to do
Add one module —
src/lib/identity-rules.ts— that is the single source of truth, and havesign-up, the account panel and the client-side
patternattributes all read from it.Username, the intersection of all three systems:
^[a-z][a-z0-9._-]{0,39}$— lower-case only, must start with a letter/[-._]{2,}/and/[-._]$/.keys.gpg.rss.atom.pngsuffixesrootand anything that parses as a UUIDNormalisation is visible at the form. Lower-case the value in the field as the user types, so
what they see is what is provisioned in every system. The identity provider lower-cases silently
already; doing it visibly removes the divergence instead of hiding it, and keeps the consent record
and the provisioned account in agreement by construction.
Email: keep the trim + lower-case + 254 cap, and replace the shape check with the identity
provider's own rule (the WHATWG
<input type=email>pattern), which is the strictest of the three.De-duplicate it — the same regex is currently copied into two modules.
Definition of done
an upgrade that changes a rule fails a test instead of a user
Part of gitborg/gitborg-docs#66.