Azure / Azure/static-web-apps-cli

Auth Emulator - Indicate valid Username characters when invalid character(s) submitted

Offen
#269 4 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
priority: low (P2) scope: auth status: need e2e tests type: bug
Vorherrschende Sprache
TypeScript
Sterne
668
Forks
156
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

**Is your feature request related to a problem? Please describe.**

Using the Auth Emulator page for GitHub (may be the same for other Identity Providers):
http://localhost:4280/.auth/login/github

If the user enters invalid characters for `Username`, an attempt to submit the form fails "silently" in the UI.

Example value for `Username`:

`یونیکد`

The console gives additional information:

_The string to be encoded contains characters outside of the Latin1 range._

`
Uncaught DOMException: Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.
at saveCookie (http://localhost:4280/.auth/login/github:168:54)
at HTMLFormElement. (http://localhost:4280/.auth/login/github:316:11)
at HTMLFormElement.dispatch (https://ajax.aspnetcdn.com/ajax/jquery/jquery-3.2.1.min.js:3:10316)
at HTMLFormElement.q.handle (https://ajax.aspnetcdn.com/ajax/jquery/jquery-3.2.1.min.js:3:8343)
`

**Describe the solution you'd like**
If it is required that Username characters be in the Latin1 range, add a validation message near the Username field in the UI.
If the full range of Unicode characters is allowed, adjust logic, to allow such characters.

**Describe alternatives you've considered**
Open the DevTools Console while running, to view run-time exceptions

**Additional context**
Exception is thrown in this source code file:
https://github.com/Azure/static-web-apps-cli/blob/main/src/public/auth.html

```Javascript
function saveCookie(formElement) {
const data = localStorage[hashStorageKey(formElement)];
document.cookie = `StaticWebAppsAuthCookie=${btoa(data)}; path=/`;
}
```

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne in src/public/auth.html, insbesondere bei saveCookie und dem im Issue gezeigten Übermittlungspfad des Username-Formulars. Reproduziere den Fehler mit dem bereitgestellten Unicode-Wert und untersuche die aktuelle Feldvalidierung sowie den btoa-Aufruf. Erledigt ist die Aufgabe, wenn die UI nicht mehr stillschweigend fehlschlägt: Sie erklärt entweder, welche Username-Zeichen akzeptiert werden, oder unterstützt den vollständigen vom Projekt vorgesehenen Bereich.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript
Bereich
authentication, frontend
Issue-Typ
Feature
Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.