Skip to content

daytrader-go: auth - #2

Open
devin-ai-integration[bot] wants to merge 2 commits into
migration/daytrader-gofrom
devin/1794800000-go-auth
Open

devin-ai-integration[bot] wants to merge 2 commits into
migration/daytrader-gofrom
devin/1794800000-go-auth

Conversation

@devin-ai-integration

Copy link
Copy Markdown

Summary

Ports the auth area of DayTrader 3 to the Go target: login, invalid login, logout, the welcome page and the HTTP 500 page. Only daytrader-go/internal/features/auth/ and daytrader-go/templates/auth_*.html are touched.

Legacy Go
TradeServletAction.doLogin + TradeSLSBBean.login + AccountDataBean.login login (web.RegisterPublicAction("login")) + loginAccount
TradeServletAction.doLogout + TradeSLSBBean.logout logout (web.RegisterAction("logout")) + logoutAccount
doWelcome + welcome.jsp welcome (web.RegisterWelcome, also GET /welcome.jsp) + auth_welcome
error.jsp (web.xml <error-page>) errorPage (web.RegisterErrorPage) + auth_error
  • login reads web.Param(r, "uid") / web.Param(r, "passwd"), so register can forward to it. In one app.Store.InTx it checks the password (exact match, like String.equals), sets lastlogin and adds one to logincount. Then it sets session.UserID and session.CreationDate and calls app.Forward(w, r, session, "home", {"results": "Ready to Trade"}).
  • A wrong password or an unknown user answers HTTP 500 with the error page, as recorded in parity/transcripts/09-invalid-login.json (legacy: EJBException -> ServletException -> error.jsp). The session is not signed in.
  • logout adds one to logoutcount in a transaction, invalidates the session and shows the welcome page with no status line.

Parity

make parity printed PASS for these scenario ids:

Branches combined (local throwaway branch, not pushed) PASS
this branch alone 09-invalid-login
this branch + devin/1794800000-go-account (7ffbcd0) + devin/1794800000-go-market (6e78edb) 01-login, 02-home, 08-account-update, 09-invalid-login, 10-logout

The other scenarios in that combination were DIFF or ERROR; they need the trading and rest branches, which were not on origin when I ran it. The legacy Liberty baseline was 13/13 on the same machine.

I also compared the raw HTML with curl against Liberty on :9083 for /welcome.jsp, /app, app?action=logout and app?action=home after logout: identical except for the licence comment and one blank line (see below).

Gates, run in daytrader-go/: gofmt -l . empty, go vet ./... clean, go test ./... ok. The tests that need PostgreSQL (TestLoginAccount, TestLoginLogoutOverHTTP) ran against the make go-db database; they skip when it is not reachable, so in CI without a database only the page tests run.

Different from legacy on purpose

  • The error page does not print the stack trace or any password. Legacy error.jsp prints the full Java stack trace, and the login failure message contains both the password that was typed and the stored one. The Go page keeps the same layout and the lines Processing request / StatusCode / Message / Exception, with the error message only. The phrases the parity scenario checks are unchanged.
  • The status line on the welcome page is HTML-escaped (legacy prints it raw, and it can contain the action parameter).
  • The Apache licence header is kept as a template comment, so it is no longer sent to the browser. The JSP directive lines' blank line is also gone.
  • Content-Type of the error page is text/html (legacy: text/html;charset=ISO-8859-1). Parity normalises this.

Scaffold requests

  • web.SessionStore has no way to issue a new session id at login. Legacy keeps the id too (req.getSession(true)), so this is parity-neutral, but a Sessions.Renew(w, session) would close session fixation.
  • web.WelcomeFunc gets no session, which is fine today; nothing else was missing.

Link to Devin session: https://partner-workshops.devinenterprise.com/sessions/884bc4e2246c4272898d7f616e4bac0c
Open in Devin Desktop: https://partner-workshops.devinenterprise.com/desktop/session/884bc4e2246c4272898d7f616e4bac0c?variant=devin
Requested by: @sumitshatwara

@devin-ai-integration

Copy link
Copy Markdown
Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant