tickets

gitoria.worldapi.org #33

Login and connect logic sits in api.hl and in the shell instead of the users and tickets topic files

done

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).

  1. 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.
  2. 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.
  3. 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

  1. Atlas opened the ticket
  2. 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).

    1. 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.
    2. 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.
    3. 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.

  3. 2 comments

    1. Caramboleyo
        Write…
      • Gitoria
          Write…
      • 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.