Determine Best Auth Solution
@rmorshea ya está trabajando en esto.
Desde el 16/7/2023.
Evaluación
Este issue todavía no se ha evaluado.
Descripción
Current Situation
This stems from discussion in https://github.com/idom-team/idom/discussions/768
As explained in https://github.com/phihos/idom-auth-example-sanic, the problem we need to solve is how to securely authenticate users inside an ReactPy single page application. Usually authentication is done via Cookie or Authorization header on each HTTP request. But after the websocket connection has been established, no future headers will be sent. However, there are some ways you could try to work around this:
-
The user could push some Javascript that sends a separate auth request to your auth API and then reloads the page to reestablish the websocket connection with new auth headers, but this is not an elegant solution. It defeats the purpose of ReactPy not having to write any Javascript and having a visible reload has a negative impact on the user-experience.
-
You could also render the login page traditionally and then redirect to a new page with embedded ReactPy . But then you already split your application into two parts: "pre-auth" with traditional server-side template rendering and "post-auth" with ReactPy. Keeping both parts consistent is probably not fun.
-
You can also do authentication inside the single page app and save the auth state via
use_state. But it will be gone as soon as a websocket disconnect happens. You can mitigate this by pushing some Javascript that sets a session cookie. But now there is a new problem: Session cookies should be set with theHttpOnlyflag to prevent XSS attacks from recovering the session cookie. This can not be done (or at least is difficult to do) with Javascript. So you might end up with a security flaw in your app. -
Since you have at least one full HTTP request-response cycle you can set a session cookie with a session ID on that response if the request does not already contain a cookie with a valid session ID. That ensures that the following request for the websocket connection always contains a session ID cookie. With
use_requestwe can extract the session ID and then the server can retrieve the session data. In that data we can look up the authentication state and let ReactPy display a login form or the actual content. We can later manipulate the session data to perform a login or logout. All without the need to set a further cookie or push Javascript - provided we implement a server-side session. A rough prototype for this has been implemented here based on work done in https://github.com/phihos/idom-auth-example-sanic.
Proposed Actions
Explore the viability of each option.
- Lenguaje dominante
- Python
- Estrellas
- 8.1k
- Forks
- 332
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de reactive-python/reactpy
-
Outdated GIF in Docs Abiertopriority-3-low type-docs
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
reactive-python/reactpy#1034 ·
-
priority-2-moderate type-revision
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
reactive-python/reactpy#1319 ·
-
priority-1-high
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
reactive-python/reactpy#1277 ·
-
priority-3-low
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
reactive-python/reactpy#1273 · 1 reacción ·
-
priority-2-moderate
Dificultad 5/5 Más de una semana Aptitud para principiantes 30/100
reactive-python/reactpy#1272 · 2 reacciones ·
Todos los issues de reactive-python/reactpy
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
qgis/QGIS-Documentation#11275 ·
-
bug priority:normal ready-for-dev
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
OpenHands/extensions#626 · 1 comentario ·
-
Change observation tooltip text Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
CSCfi/sd-search-api#39 ·
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
-
please add to porn list Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
StevenBlack/hosts#3255 ·