Skip to content

feat(clerk-js): Link to external App page in OAuth Consent #6447

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
7e24a6a
feat(clerk-js): Add OAuth Application URL and update Avatar component…
jfoshee Jul 28, 2025
6b70d4f
Merge branch 'main' into jf.feat/oauth-consent-app-link
jfoshee Jul 28, 2025
72e5409
chore: add a task for running dev sandbox
jfoshee Jul 30, 2025
373ded0
support query params for new fields in oauth consent
jfoshee Jul 30, 2025
0cc8f60
Merge branch 'main' into jf.feat/oauth-consent-app-link
jfoshee Jul 30, 2025
8c20482
use spaces in tasks.json
jfoshee Jul 30, 2025
d66f708
add changeset
jfoshee Aug 1, 2025
b455d85
Merge branch 'main' into jf.feat/oauth-consent-app-link
jfoshee Aug 1, 2025
49283ea
Merge branch 'main' into jf.feat/oauth-consent-app-link
jfoshee Aug 8, 2025
efe0820
fix: use <Link> rather than <a>
jfoshee Aug 8, 2025
dcfde0e
feat: add Avatar.linkUrl rather than externalLinkUrl
jfoshee Aug 8, 2025
e87b640
fix patch notes
jfoshee Aug 8, 2025
92ede1e
fix: missed one
jfoshee Aug 8, 2025
632d779
Merge branch 'main' into jf.feat/oauth-consent-app-link
jfoshee Aug 8, 2025
76c8af4
Merge branch 'main' into jf.feat/oauth-consent-app-link
jfoshee Aug 11, 2025
03576fd
revert changes to avatar
jfoshee Aug 11, 2025
d10fb15
style: whitespace
jfoshee Aug 12, 2025
57bff23
Merge branch 'main' into jf.feat/oauth-consent-app-link
jfoshee Aug 12, 2025
ecaab41
feat(clerk-js): add `isExternal` to `ApplicationLogo` so users can sa…
jfoshee Aug 12, 2025
d437ac9
feat(clerk-js): implement href sanitization to prevent XSS attacks in…
jfoshee Aug 12, 2025
b23e967
feedback
jfoshee Aug 12, 2025
038a74a
Merge branch 'main' into jf.feat/oauth-consent-app-link
jfoshee Aug 12, 2025
96dc277
Update sad-turkeys-rhyme.md
jfoshee Aug 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/sad-turkeys-rhyme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@clerk/clerk-js': patch
'@clerk/types': patch
---

Add optional `linkUrl` to `Avatar`

Add optional `oAuthApplicationUrl` parameter to OAuth Consent mounting (which is used to provide a link to the OAuth App homepage).
13 changes: 13 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "dev:sandbox",
"path": "packages/clerk-js",
"problemMatcher": [],
"label": "Dev: Sandbox",
"detail": "npm: dev:sandbox - packages/clerk-js"
}
]
}
2 changes: 2 additions & 0 deletions packages/clerk-js/sandbox/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,8 @@ void (async () => {
scopes,
oAuthApplicationName: searchParams.get('oauth-application-name'),
redirectUrl: searchParams.get('redirect_uri'),
oAuthApplicationLogoUrl: searchParams.get('logo-url'),
oAuthApplicationUrl: searchParams.get('app-url'),
},
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { common } from '@/ui/styledSystem';
import { colors } from '@/ui/utils/colors';

export function OAuthConsentInternal() {
const { scopes, oAuthApplicationName, oAuthApplicationLogoUrl, redirectUrl, onDeny, onAllow } =
const { scopes, oAuthApplicationName, oAuthApplicationLogoUrl, oAuthApplicationUrl, redirectUrl, onDeny, onAllow } =
useOAuthConsentContext();
const { user } = useUser();
const { applicationName, logoImageUrl } = useEnvironment().displayConfig;
Expand All @@ -44,6 +44,7 @@ export function OAuthConsentInternal() {
<ConnectionHeader>
<Avatar
imageUrl={oAuthApplicationLogoUrl}
linkUrl={oAuthApplicationUrl}
size={t => t.space.$12}
rounded={false}
/>
Expand All @@ -61,6 +62,7 @@ export function OAuthConsentInternal() {
>
<Avatar
imageUrl={oAuthApplicationLogoUrl}
linkUrl={oAuthApplicationUrl}
size={t => t.space.$12}
rounded={false}
/>
Expand Down
20 changes: 18 additions & 2 deletions packages/clerk-js/src/ui/elements/Avatar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { isAbsoluteUrl } from '@clerk/shared/url';
import React from 'react';

import { Box, descriptors, Flex, Image, Text } from '../customizables';
import { Box, descriptors, Flex, Image, Link, Text } from '../customizables';
import type { ElementDescriptor } from '../customizables/elementDescriptors';
import type { InternalTheme } from '../foundations';
import type { PropsOfComponent } from '../styledSystem';
Expand All @@ -15,6 +16,11 @@ type AvatarProps = PropsOfComponent<typeof Flex> & {
rounded?: boolean;
boxElementDescriptor?: ElementDescriptor;
imageElementDescriptor?: ElementDescriptor;
/**
* URL to navigate to when the avatar is clicked.
* If it's an absolute URL, it opens in a new tab.
*/
linkUrl?: string;
};

export const Avatar = (props: AvatarProps) => {
Expand All @@ -28,6 +34,7 @@ export const Avatar = (props: AvatarProps) => {
sx,
boxElementDescriptor,
imageElementDescriptor,
linkUrl,
} = props;
const [error, setError] = React.useState(false);

Expand Down Expand Up @@ -65,7 +72,16 @@ export const Avatar = (props: AvatarProps) => {
sx,
]}
>
{ImgOrFallback}
{linkUrl && linkUrl.trim() ? (
<Link
href={linkUrl}
isExternal={isAbsoluteUrl(linkUrl)}
>
{ImgOrFallback}
</Link>
) : (
ImgOrFallback
)}

{/* /**
* This Box is the "shimmer" effect for the avatar.
Expand Down
2 changes: 1 addition & 1 deletion packages/clerk-js/src/ui/primitives/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const Link = (props: LinkProps): JSX.Element => {
onClick={onClickHandler}
href={href || ''}
target={href && isExternal ? '_blank' : undefined}
rel={href && isExternal ? 'noopener' : undefined}
rel={href && isExternal ? 'noopener noreferrer' : undefined}
css={applyVariants(props) as any}
>
{children}
Expand Down
4 changes: 4 additions & 0 deletions packages/types/src/clerk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2003,6 +2003,10 @@ export type __internal_OAuthConsentProps = {
* Logo URL of the OAuth application.
*/
oAuthApplicationLogoUrl?: string;
/**
* URL of the OAuth application.
*/
oAuthApplicationUrl?: string;
/**
* Scopes requested by the OAuth application.
*/
Expand Down