Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Como un desarrollador, quiero no tener que dar mi cookie (o mi contraseña!) para tener acceso al API #5242

Open
2 tasks
lhchavez opened this issue Mar 17, 2021 · 1 comment

Comments

@lhchavez
Copy link
Member

lhchavez commented Mar 17, 2021

Comportamiento Esperado

Casi cualquier API te permite usar un token que no está asociado a tu login de la página. Esto es útil para gente que quiere interactuar con omegaUp desde CLI o CI.

Comportamiento Actual

El API espera que se le pase el cookie con el que inició sesión desde el navegador. si inicia sesión en otro navegador, esa cookie se invalida y se pierde acceso a la API.

Posible Solución

Hay que hacer otra tabla (APITokens) que guarde tokens que se pueden usar para la API. Y meterle rate-limiting y más logging a todas las APIs para contraatacar los inevitables accidentes (o abusos).

Cosas faltantes:

Alternativas consideradas

Si no lo hacemos, la gente va a seguir usando workarounds dolorosos para todos los involucrados.

Contexto

El CI del comi seguido se muere por esto.
un usuario (@Apocryphon-X) está desarrollando un CLI para el API.

Tu ambiente

N/A.

@Apocryphon-X
Copy link
Member

Apocryphon-X commented Mar 17, 2021

Sería mucho más sencillo implementar funciones de ese modo! Igualmente, en mi caso, el usuario ya no tendría que poner su contraseña a cada rato para realizar un envío o alguna otra acción.

Bastaría con validar el API Token registrado la primera vez que se hiciese el login para proceder con lo demas

lhchavez added a commit to lhchavez/omegaup that referenced this issue Mar 21, 2021
Este cambio agrega la tabla de `API_Tokens` para poder autenticar ante
el API sin necesidad de usar el cookie.

Part of: omegaup#5242
lhchavez added a commit to lhchavez/omegaup that referenced this issue Mar 21, 2021
Este cambio agrega la tabla de `API_Tokens` para poder autenticar ante
el API sin necesidad de usar el cookie.

Part of: omegaup#5242
lhchavez added a commit to lhchavez/omegaup that referenced this issue Mar 21, 2021
Este cambio agrega la tabla de `API_Tokens` para poder autenticar ante
el API sin necesidad de usar el cookie.

Part of: omegaup#5242
lhchavez added a commit that referenced this issue Mar 21, 2021
Este cambio agrega la tabla de `API_Tokens` para poder autenticar ante
el API sin necesidad de usar el cookie.

Part of: #5242
lhchavez added a commit to lhchavez/omegaup that referenced this issue Mar 22, 2021
Este cambio permite el uso de API Tokens para autenticarse ante el API.
Para usarlos, se debe enviar una cabecera HTTP:

    Authorization: token 92d8c5a0eceef3c05f4149fc04b62bb2cd50d9c6

O si se desea interactuar mediante una identidad asociada,

    Authorization: token Credential=92d8c5a0eceef3c05f4149fc04b62bb2cd50d9c6,Username=groupname:username

Existe un límite de 1000 peticiones por hora usando este mecanismo.

Part of: omegaup#5242
lhchavez added a commit to lhchavez/omegaup that referenced this issue Mar 22, 2021
Este cambio permite el uso de API Tokens para autenticarse ante el API.
Para usarlos, se debe enviar una cabecera HTTP:

    Authorization: token 92d8c5a0eceef3c05f4149fc04b62bb2cd50d9c6

O si se desea interactuar mediante una identidad asociada,

    Authorization: token Credential=92d8c5a0eceef3c05f4149fc04b62bb2cd50d9c6,Username=groupname:username

Existe un límite de 1000 peticiones por hora usando este mecanismo.

Part of: omegaup#5242
lhchavez added a commit that referenced this issue Mar 22, 2021
Este cambio permite el uso de API Tokens para autenticarse ante el API.
Para usarlos, se debe enviar una cabecera HTTP:

    Authorization: token 92d8c5a0eceef3c05f4149fc04b62bb2cd50d9c6

O si se desea interactuar mediante una identidad asociada,

    Authorization: token Credential=92d8c5a0eceef3c05f4149fc04b62bb2cd50d9c6,Username=groupname:username

Existe un límite de 1000 peticiones por hora usando este mecanismo.

Part of: #5242
lhchavez added a commit to lhchavez/omegaup that referenced this issue Mar 22, 2021
Este cambio permite crear hasta 5 API tokens. También permite revocar
tokens.

Part of: omegaup#5242
lhchavez added a commit to lhchavez/omegaup that referenced this issue Mar 22, 2021
Este cambio permite crear hasta 5 API tokens. También permite revocar
tokens.

Part of: omegaup#5242
lhchavez added a commit that referenced this issue Mar 22, 2021
Este cambio permite crear hasta 5 API tokens. También permite revocar
tokens.

Part of: #5242
lhchavez added a commit to lhchavez/omegaup that referenced this issue Mar 22, 2021
Este cambio permite ver qué tokens han sido creados.

Part of: omegaup#5242
lhchavez added a commit to lhchavez/omegaup that referenced this issue Mar 22, 2021
Este cambio permite ver qué tokens han sido creados.

Part of: omegaup#5242
lhchavez added a commit that referenced this issue Mar 22, 2021
Este cambio permite ver qué tokens han sido creados.

Part of: #5242
@lhchavez lhchavez changed the title [FEATURE] Como un desarrollador, quiero no tener que dar mi cookie para tener acceso al API [FEATURE] Como un desarrollador, quiero no tener que dar mi cookie (o mi contraseña!) para tener acceso al API Mar 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants