Skip to content

feat(server): read the authorization endpoint's request strictly - #505

Merged
osanderson merged 3 commits into
mainfrom
feat/server-begin-authorization-from-http
Oct 2, 2026
Merged

osanderson merged 3 commits into
mainfrom
feat/server-begin-authorization-from-http

Conversation

@osanderson

Copy link
Copy Markdown
Collaborator

Summary

This is the second library addition from the DevX review. It's separate from #504, with which it shares no logic.

func BeginAuthorizationRequestFromHTTP(r *http.Request) (BeginAuthorizationRequest, error)

It reads the client_id and request_uri a client sends the browser to the authorization endpoint with after PAR (RFC 9126 §4).

Why. Every embedder (the five demos and cmd/conformance-as) read them with r.URL.Query().Get, which silently takes the first of a repeated parameter. RFC 6749 §3.1 says request parameters "MUST NOT be included more than once". FAPIgo's other endpoints already refuse duplicates (that's what FormRequestFromHTTP is for); the authorization endpoint was the one place every integrator hand-rolled the parsing.

Behaviour:

  • Refused: a repeated client_id or request_uri, or a malformed query, gets an invalid_request *Error. The doc says to render it locally, never as a redirect: the request hasn't yet named a redirect URI it can be trusted with.
  • Passed through: a missing value is left empty for BeginAuthorization to answer, as it does any unrecognised request_uri or client_id today.
  • Ignored: other parameters, as before. With PAR, the request's real parameters come from the pushed request.

Adopted:

  • the five demos with an authorization server;
  • cmd/conformance-as, whose suite-only error-redirect path still reads redirect_uri and state from the raw query, but now takes client_id from the strictly parsed request;
  • GETTING_STARTED's login step.

Tests

  • Both values are read, and an unrelated parameter is ignored.
  • No parameters give empty values and no error.
  • A repeated request_uri, a repeated client_id and a malformed query each get invalid_request.
  • Other checks:
    • go test -race ./... and golangci-lint pass;
    • the five demo modules and cmd/conformance-as pass their tests and lint;
    • GETTING_STARTED's snippets compile.

🤖 Generated with Claude Code

server.BeginAuthorizationRequestFromHTTP(r) reads the client_id and
request_uri a client sends the browser with after a pushed
authorization request. Every embedder read them with
r.URL.Query().Get, which silently takes the first of a repeated
parameter, though RFC 6749 §3.1 says a parameter "MUST NOT be included
more than once". This package's other endpoints already refuse
duplicates through FormRequestFromHTTP; the authorization endpoint was
the one place every integrator hand-rolled the parsing.

A repeated client_id or request_uri, or a malformed query, is an
invalid_request *Error, to render locally rather than redirect. A
missing value is left for BeginAuthorization to answer, as it does
today.

The five demos with an authorization server, cmd/conformance-as and
GETTING_STARTED now use it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@osanderson
osanderson force-pushed the feat/server-begin-authorization-from-http branch from cac6b85 to 6ccec35 Compare October 2, 2026 04:20
osanderson and others added 2 commits October 2, 2026 12:23
…r redirect

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sonarqubecloud

sonarqubecloud Bot commented Oct 2, 2026

Copy link
Copy Markdown

@osanderson
osanderson merged commit f03ab22 into main Oct 2, 2026
17 checks passed
@osanderson
osanderson deleted the feat/server-begin-authorization-from-http branch October 2, 2026 04:26
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