Repository navigation
Add personal connection tokens with read and control scopes [skip deploy] #no-deploy - #13
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contexto
El servidor MCP que quedó a medio hacer entraba a la API con una sola cuenta de servicio (
SMARTPOT_EMAILySMARTPOT_PASSWORD): cualquiera que se conectara actuaba como esa cuenta. Ahora cada persona crea en la PWA suspropias conexiones (tokens
spt_…con alcance de solo lectura o de control), el MCP reenvía el token de quien llamay la API decide qué puede hacer. Este cambio va en cuatro repos: DB-Postgre (tabla), API Go (tokens y guard),
SmartPot-MCP (servidor) y Web-Solid (Perfil › Conexiones);
.githublo integra en la demo beta.Cambio
connections(hexagonal: modelo, puerto, servicio, controlador y adaptador de PostgreSQL):GET/POST /api/v1/connectionsyDELETE /api/v1/connections/{id}. El token tiene 256 bits aleatorios, solo sedevuelve al crearlo (
Cache-Control: no-store) y se guarda su SHA-256. Máximo 10 por cuenta, vigencia opcional de1 a 365 días y último uso registrado como mucho una vez por minuto.
Bearer spt_…además del JWT. Con una conexión:READsolo haceGET;CONTROLademás escribe y acciona actuadores.Verificación
gofmt,go vetygo test ./...en verde; pruebas nuevas del guard (alcances y rutas vetadas) y del servicio(token en claro nunca guardado, revocación, vencimiento, límite y escritura del último uso).
accionar y al administrar conexiones, y 401 tras revocarla.