Skip to content

feat: reuse browser session with session_id cookie - #62

Merged
florentx merged 1 commit into
masterfrom
feat/login-session
Nov 27, 2026
Merged

florentx merged 1 commit into
masterfrom
feat/login-session

Conversation

@florentx

Copy link
Copy Markdown
Member

Summary

Some Odoo servers do not accept password login, for example when users must
sign in with OAuth (auth_oauth), and API keys are not available to them.
This adds a way to use Odooly with such servers: reuse the session_id cookie
of a browser session.

  • Client.login_session(session_id), also Client(server, session_id=...)
  • Command line option --session-id, with a server URL or with --env
  • The user and database are read from /web/session/get_session_info
  • HTTPSession.set_cookie(), for both requests and urllib backends

The session is shared with the browser, so Odooly never ends or replaces it:

  • it never sends this cookie to /web/session/authenticate, /web/login,
    /web/become or /web/session/destroy
  • logging in as another user with a password uses a separate cookie; switching
    back to the shared user restores the browser cookie
  • env.session_destroy() only removes the cookie from Odooly
  • env.sudo() raises an error instead of turning the browser session into superuser

Limitations

  • When the browser session expires, calls fail with "session expired": run again
    with a fresh cookie.
  • "Security Control" checks still ask for a password.
  • The session_id is not read from odooly.ini.

Tests

  • New tests with a fake Odoo 17 server that checks which cookie each endpoint receives.
  • Full test suite passes with both HTTP backends (ODOOLY_SSL_UNVERIFIED=1 for urllib).
  • Docs build without warnings.

🤖 Generated with Claude Code

@florentx
florentx force-pushed the feat/login-session branch 4 times, most recently from a46465b to 611538c Compare November 27, 2026 00:11
Add argument session_id to Client and Client.login, and option
--session-id, to reuse an authenticated Web session when password
login is disabled (e.g. OAuth sign-in).

The Web session of each user is cached and reused when switching user
or environment.  session_destroy() terminates the session of its own
environment.  sudo() on a browser session warns that it becomes
Superuser; the Superuser session is reused, never another session.
@florentx
florentx merged commit b8ba5f7 into master Nov 27, 2026
12 checks passed
@florentx
florentx deleted the feat/login-session branch November 27, 2026 09:57
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