Skip to content

Add OAuth2 authorization page for authorization code flow#739

Draft
Copilot wants to merge 3 commits into
developfrom
copilot/add-oauth2-authorization-server-interface
Draft

Add OAuth2 authorization page for authorization code flow#739
Copilot wants to merge 3 commits into
developfrom
copilot/add-oauth2-authorization-server-interface

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 30, 2026

Implements the webapp-side OAuth2 authorization code flow. Users are presented with a consent screen showing the requesting application's metadata and requested scopes, and can approve or decline access.

API Client

  • Regenerated from upstream swagger to include OAuth types (OAuthClientMetadataResponseData, OauthAuthorizeData, AccessTokenScopeData, etc.)
  • Updated generated OAuth client metadata types to include the new URI fields (logo_uri, client_uri, policy_uri, tos_uri)

Route & Page

  • /_auth/oauth/authorize — protected route with Zod search param validation for client_id, redirect_uri, code_challenge (required) and scope, state (optional)
  • OAuthAuthorizePage — consent UI showing client name, app logo, subtle links to client information / privacy policy / terms of service, required scope tags as provided by the backend, short internationalized scope descriptions, security note, approve/decline actions
  • Approve → calls GET /api/v1/oauth/authorize with PKCE params, follows redirect
  • Decline → redirects to redirect_uri with error=access_denied and state per RFC 6749 §4.1.2.1

Hooks & Data Layer

  • useOAuthClient(clientId) — fetches client metadata via GET /api/v1/oauth/clients/{clientId}
  • useOAuthAuthorize() — mutation wrapping the authorize endpoint
  • OAuthClient internal model strips client_secret and client_id_issued_at while mapping the new client URI metadata fields needed by the consent UI

i18n

  • OAuth consent translations added for all 5 languages (en, de, fr, es, it)
  • Scope keys use oauth.scopes.products_write / oauth.scopes.shops_manage with short descriptions for non-technical users
  • Added localized labels for the consent-page client metadata links and logo alt text

Tests (29)

  • Data mapping: field correctness, URI metadata mapping, secret exclusion, empty scopes
  • Route: meta tags, SSR disabled, param validation, defaults, missing required params
  • Component: loading/error states, logo and metadata links, scope rendering, approve/deny behavior, button disabled states, mutation error display, accessibility labels

Copilot AI linked an issue May 30, 2026 that may be closed by this pull request
- Regenerate API client to include OAuth types from swagger
- Add internal data model for OAuth client metadata (OAuthClient.ts)
- Add useOAuthClient hook to fetch client metadata
- Add useOAuthAuthorize hook for authorization mutation
- Add OAuthAuthorizePage component with approve/decline UI
- Add /oauth/authorize route under _auth layout (requires auth)
- Add i18n translations for OAuth scopes (de, en, es, fr, it)
- Add 28 tests (data mapping, route validation, component behavior)
@cloudflare-workers-and-pages
Copy link
Copy Markdown
Contributor

cloudflare-workers-and-pages Bot commented May 30, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
aura-historia-staging ca23633 Commit Preview URL

Branch Preview URL
May 31 2026, 11:44 AM

Copilot AI changed the title [WIP] Add OAuth2 Authorization-Server Interface Add OAuth2 authorization page for authorization code flow May 30, 2026
Copilot AI requested a review from bruderj15 May 30, 2026 08:54
@sonarqubecloud
Copy link
Copy Markdown

@bruderj15
Copy link
Copy Markdown
Member

@copilot solid start.

The backend added additional fields for oauth-client metadata, see Changelog.

Please use them to display the app logo and subtly provide links to ToS, Privacy policy and client-uri (more information about the client). Keep in mind users are NON-TECHNICAL.

Also please display the required scopes: display the scope tag as provided by backend AND display an internationalized short description (probably one short sentence is enough) description of what each required scope entails/does.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 31, 2026

@copilot solid start.

The backend added additional fields for oauth-client metadata, see [Changelog](https://github.com/aura-historia/internal-api/blob/master/CHANGELOG.md#2026-05-31---oaut...

Addressed in ca23633.

@bruderj15
Copy link
Copy Markdown
Member

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.

Add OAuth2 Authorization-Server Interface

2 participants