Login and connect logic sits in api.hl and in the shell instead of the users and tickets topic files
opened by Atlas
opened · updated
Audit (layouts.worldapi.org#6), checklist item: 16.5 (API, faces and page handlers are thin wrappers; no business logic in api.hl, project.hl or components).
- lib/api.hl:51-84 loginCallback and loginFailed (about 30 lines) do the real login work: they mint a session, retire the old session (session-fixation rule), set s.user, s.data.tag and s.data.loginError, save it and build the redirect response with headers and cookie.
- components/main.hl:162-173 (face gitoriaLogin) does the same login a second time in the component: session.user = { id = ... }, a new random tag, session.data.tag, emit client gitoriaSignedIn. The two copies differ (the face does not retire an old session), which is a security-relevant drift.
- lib/api.hl:95-119 connectStart and connectBack keep the connect nonce and note logic (s.data.connectState = slug + '.' + nonce, s.data.connectNote) in the route, around the topic call finishConnect.
Framework way (code order rules 4 and 5): lib/users.hl holds the login (one function that starts a session for a user and returns the tag), lib/tickets.hl holds the connect state; api.hl and the shell face only check the input, call it and answer.
History
Atlas opened the ticket Atlas edited the ticket Summary before
Audit (layouts.worldapi.org#6), checklist item: 16.5 (API, faces and page handlers are thin wrappers; no business logic in api.hl, project.hl or components).
- lib/api.hl:63-84 loginCallback and loginFailed (about 30 lines) do the real login work: they mint a session, retire the old session (session-fixation rule), set s.user, s.data.tag and s.data.loginError, save it and build the redirect response with headers and cookie.
- components/main.hl:152-163 (face gitoriaLogin) does the same login a second time in the component: session.user = { id = ... }, a new random tag, session.data.tag, emit client gitoriaSignedIn. The two copies differ (the face does not retire an old session), which is a security-relevant drift.
- lib/api.hl:111-134 connectStart and connectBack keep the connect nonce and note logic (s.data.connectState = slug + '.' + nonce, s.data.connectNote) in the route, around the topic call finishConnect.
Framework way (code order rules 4 and 5): lib/users.hl holds the login (one function that starts a session for a user and returns the tag), lib/tickets.hl holds the connect state; api.hl and the shell face only check the input, call it and answer.
2 comments
Gitoria changed the state done
Reading is open to everyone. To comment or change the state, log in with ident (top right) and choose a display name.
Write…
Write…