Skip to content

feat(oauth): add client branding support for OAuth authorization pages - #9

Merged
aspiers merged 1 commit into
hypercerts-org:devfrom
aspiers:trusted-client-branding
Jan 14, 2026
Merged

aspiers merged 1 commit into
hypercerts-org:devfrom
aspiers:trusted-client-branding

Conversation

@aspiers

@aspiers aspiers commented Jan 8, 2026

Copy link
Copy Markdown
Collaborator

Without this patch, OAuth clients cannot customize the appearance of
authorization pages when users authenticate. All clients see the same
default Bluesky branding regardless of their identity.

This is a problem because trusted third-party applications (like the
SDS demo) may want to provide a branded experience during the OAuth
flow to maintain visual consistency and user trust.

This patch solves the problem by:

  • Adding a branding.css field to OAuth client metadata schema
  • Allowing trusted clients (configured in PDS trustedClients) to inject
    custom CSS into authorization pages
  • Enhancing sds-demo to include example branding CSS

The branding CSS is only applied for clients marked as trusted in the
PDS configuration, preventing untrusted clients from manipulating the
authorization UI.

Co-authored-by: Claude noreply@anthropic.com

@vercel

vercel Bot commented Jan 8, 2026

Copy link
Copy Markdown

@aspiers is attempting to deploy a commit to the Hypercerts Foundation Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Jan 8, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
sds-demo Ready Ready Preview, Comment Jan 14, 2026 1:00pm

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds client branding support for OAuth authorization pages, allowing trusted OAuth clients to inject custom CSS to maintain visual consistency during the authentication flow. The implementation restricts this feature to clients explicitly marked as trusted in the PDS configuration to prevent unauthorized UI manipulation.

Changes:

  • Added branding.css field to OAuth client metadata schema with comprehensive documentation
  • Modified CSS building logic to inject client-specific CSS only for trusted clients
  • Updated authorization page rendering to compute client-specific CSS per request
  • Added example branding CSS in sds-demo demonstrating custom button styling and brand indicators

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
packages/oauth/oauth-types/src/oauth-client-metadata.ts Adds optional branding object with css field to client metadata schema
packages/oauth/oauth-provider/src/customization/build-customization-css.ts Extends CSS building function to conditionally inject client branding CSS for trusted clients only
packages/oauth/oauth-provider/src/router/assets/send-authorization-page.ts Moves CSS generation from factory-level to per-request to support dynamic client branding
packages/sds-demo/rollup.config.js Adds example branding CSS with custom colors, button styling, and brand indicator

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +35 to +42
// Generate CSS with client branding
const customizationCss = cssCode(
buildCustomizationCss({
branding: customization.branding,
clientMetadata: data.client.metadata,
isTrusted: data.client.info.isTrusted,
}),
)

Copilot AI Jan 10, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CSS generation has been moved from pre-computation (line 17 in the factory function) to per-request computation inside the handler function. This creates a performance regression because buildCustomizationCss will be called for every authorization request instead of once when the factory is initialized.

For authorization pages that don't use client branding (non-trusted clients or clients without branding), this adds unnecessary overhead on every request. Consider maintaining the pre-computed customizationCss for the base case and only computing client-specific CSS when needed.

Copilot uses AI. Check for mistakes.

@aspiers aspiers Jan 12, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed as #14 to be done as a follow-up.

Comment thread packages/oauth/oauth-provider/src/customization/build-customization-css.ts Outdated
Comment on lines +193 to +201
/* Add a subtle brand indicator */
.auth-form::before {
content: "Powered by SDS Demo";
display: block;
text-align: center;
font-size: 0.75rem;
color: rgb(99 102 241);
margin-bottom: 1rem;
}

Copilot AI Jan 10, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pseudo-element selector '.auth-form::before' assumes that an element with class 'auth-form' exists in the authorization page markup. If this class doesn't exist or is renamed in the future, the branding indicator won't be displayed. Consider documenting the expected DOM structure for custom CSS, or use more defensive CSS that won't break if the structure changes.

Copilot uses AI. Check for mistakes.
Without this patch, OAuth clients cannot customize the appearance of
authorization pages when users authenticate. All clients see the same
default Bluesky branding regardless of their identity.

This is a problem because trusted third-party applications (like the
SDS demo) may want to provide a branded experience during the OAuth
flow to maintain visual consistency and user trust.

This patch solves the problem by:
- Adding a `branding.css` field to OAuth client metadata schema
- Allowing trusted clients (configured in PDS trustedClients) to inject
  custom CSS into authorization pages
- Enhancing sds-demo to include example branding CSS

The branding CSS is only applied for clients marked as trusted in the
PDS configuration, preventing untrusted clients from manipulating the
authorization UI.

Co-authored-by: Claude <noreply@anthropic.com>
@aspiers
aspiers force-pushed the trusted-client-branding branch from 22c2def to 2789990 Compare January 14, 2026 12:40
@aspiers
aspiers merged commit aff3a65 into hypercerts-org:dev Jan 14, 2026
17 of 32 checks passed
@aspiers
aspiers deleted the trusted-client-branding branch January 14, 2026 13:02

This branch was successfully deployed

1 active deployment
Preview — 2789990b Deployed Jan 14, 2026 by vercel[bot]
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.

2 participants