Azure / Azure/static-web-apps-cli

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

Abierto
#269 4 comentarios 0 reacciones 0 asignados Ver en GitHub
priority: low (P2) scope: auth status: need e2e tests type: bug
Lenguaje dominante
TypeScript
Estrellas
668
Forks
156
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

**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=/`;
}
```

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Comienza en src/public/auth.html, especialmente en saveCookie y en la ruta de envío del formulario Username mostrada en el issue. Reproduce el fallo con el valor Unicode proporcionado e inspecciona la validación actual del campo y la llamada a btoa. La tarea estará terminada cuando la UI ya no falle silenciosamente: o bien explica qué caracteres de Username se aceptan, o bien admite todo el rango previsto por el proyecto.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
javascript
Área
authentication, frontend
Tipo de issue
Nueva funcionalidad
Dificultad
2/5
Tiempo estimado
1-3 horas
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.