Skip to content

feat(endpoint-auth): support profile scope and add userinfo endpoint - #938

Merged
paulrobertlloyd merged 1 commit into
mainfrom
feat/endpoint-auth-profile-scope
Sep 13, 2026
Merged

paulrobertlloyd merged 1 commit into
mainfrom
feat/endpoint-auth-profile-scope

Conversation

@rmdes

@rmdes rmdes commented Sep 5, 2026

Copy link
Copy Markdown
Collaborator

Closes #885, following what we agreed there: configuration first, discovery as the fallback, email untouched, /userinfo in the same PR and re-discovering on each request.

What changes

  • profile option on @indiekit/endpoint-auth: { name, url, photo }, each key optional. Configured values are used as-is; anything missing is discovered from the h-card on the user’s site (lib/profile.js): the h-card whose u-url is the profile URL, else the first one. No h-card and nothing configured means the scope yields nothing, as today. A site that can’t be fetched, or an address that isn’t a domain name (same guard as client discovery), falls back to the configured values.
  • profile scope is now supported (scope.js), so it appears enabled on the consent form.
  • Profile URL and access token responses include profile when the granted scope contains profile. Only JSON responses carry it; the specification defines profile information for JSON only, so form-encoded responses are unchanged.
  • GET /auth/userinfo returns the same object for a bearer token granted profile, discovering afresh each time. A token without profile gets insufficient_scope (403); an invalid token unauthorized (401). Announced as userinfo_endpoint in server metadata and set on application.userinfoEndpoint like the other endpoints.
  • README option row.

authorizationController and tokenController become factories taking the plug-in options, so the configured profile reaches them without going through application state.

Tests

  • Unit (test/unit/profile.js): discovery, configured-first merge, fetch failure, no h-card, non-domain address.
  • Integration: profile in the access token response, profile in the profile URL response, /userinfo with configured value overriding a discovered one, 403 without scope, 401 with an invalid token, userinfo_endpoint in metadata.
  • New fixture helpers/fixtures/html/profile.html and mock-agent intercepts for the user’s site; testConfig passes @indiekit/endpoint-auth options through.

Verified locally: node --test packages/endpoint-auth/test/**/*.js 79/79, packages/indiekit integration 33/33, eslint and prettier clean.

Caching of discovered values is deliberately left out; tracked separately as #939.

@rmdes rmdes added the plugin-endpoint Endpoint plug-in label Sep 7, 2026
Comment thread helpers/config/index.js
Return profile information (name, url, photo) with the profile URL and
access token responses when the profile scope is granted, and from a new
userinfo endpoint. Values come from the plug-in’s profile option first,
with anything missing discovered from the representative h-card on the
user’s site. Announce the endpoint in server metadata.

Closes #885
@rmdes
rmdes force-pushed the feat/endpoint-auth-profile-scope branch from 6578789 to 0751857 Compare September 13, 2026 11:01
@paulrobertlloyd
paulrobertlloyd merged commit 7a27fa6 into main Sep 13, 2026
1 check passed
@paulrobertlloyd
paulrobertlloyd deleted the feat/endpoint-auth-profile-scope branch September 13, 2026 23:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plugin-endpoint Endpoint plug-in

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IndieAuth: support profile scope by discovering author metadata from the user's site

2 participants