Skip to content

Use the current Roller session during OAuth authorization - #165

Open
snoopdave wants to merge 1 commit into
masterfrom
oauth-authorize-session-binding
Open

Use the current Roller session during OAuth authorization#165
snoopdave wants to merge 1 commit into
masterfrom
oauth-authorize-session-binding

Conversation

@snoopdave

Copy link
Copy Markdown
Contributor

The OAuth 1.0a consent step should authorize the user who is signed in, the way
the rest of Roller's admin and editor UI resolves identity from the session.
This change moves it onto that model and tightens request-token approval into a
single conditional update.

What changed

  • Derive the authorizing identity from the Roller session and require an enabled
    user. A request with no session goes through the normal login flow.
  • Keep the bound-consumer check, comparing against the session user.
  • For backwards compatibility, a userId / xoauth_requestor_id request
    parameter is still accepted when it agrees with the session user, and
    rejected otherwise; it is not used to choose the identity.
  • Approve the request token with one conditional update — success is defined as
    exactly one row changed — rather than a separate load then store, so approval
    is one-shot.
  • Return a single oauth_problem=permission_denied (403) for every refusal, so
    the response does not vary with the reason.
  • Deprecate markAsAuthorized in favour of authorizeRequestToken.

Tests

AuthorizationServletTest covers identity taken from the session, a mismatched
userId parameter, disabled accounts, the bound-consumer refusal, and the
generic refusal path. JPAOAuthManagerTest exercises the conditional update
against Derby: a mismatched token changes no row, the exact pending token
succeeds once, and a second use of the same token changes no row.

Derive the approving identity from the Roller session, as the rest of the UI
does, and require the account to be enabled. Without a session the request goes
to the login flow as before.

A consumer key bound to a specific user may still only be approved by that user;
a site-wide key is approved as whoever is logged in. Clients that continue to
post the identity are accepted when the value agrees with the session and
refused otherwise.

Add OAuthManager.authorizeRequestToken(consumerKey, requestToken, userName),
backed by a named update that matches the consumer key, the exact request token,
an unauthorized record, and no access token, and reports whether one row changed.
Approval is therefore one-shot, with no read-then-write window. markAsAuthorized
is deprecated: it keyed on the consumer alone and did not name the token being
approved.

Refusals share one response so callers cannot tell refusals apart.

Drop the identity field from the consent form and give it the standard salt
field, and validate that token on the consent URL only. The request-token and
access-token endpoints carry an OAuth signature and are left out of that mapping.

Tests: AuthorizationServletTest.

Claude-Session: https://claude.ai/code/session_01A1fhY1E2PCFU6UAPXu2WtV
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant