Skip to content
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

Do not display the client_name of untrusted clients #2847

Merged
merged 2 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .changeset/wicked-items-peel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@atproto/oauth-provider": patch
---

Do not display the client_name of untrusted clients
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,12 @@ export function AcceptForm({
</div>
)}
<p>
<ClientName clientId={clientId} clientMetadata={clientMetadata} /> is
asking for permission to access your account (
<ClientName
clientId={clientId}
clientMetadata={clientMetadata}
clientTrusted={clientTrusted}
/>{' '}
is asking for permission to access your account (
<AccountIdentifier account={account} />
).
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,28 @@ import { UrlViewer } from './url-viewer'
export type ClientNameProps = {
clientId: string
clientMetadata: OAuthClientMetadata
clientTrusted: boolean
loopbackClientName?: string
} & HTMLAttributes<Element>

export function ClientName({
clientId,
clientMetadata,
clientTrusted,
loopbackClientName = 'An application on your device',
...attrs
}: ClientNameProps) {
if (clientTrusted && clientMetadata.client_name) {
return <span {...attrs}>{clientMetadata.client_name}</span>
}

if (isOAuthClientIdLoopback(clientId)) {
return <span {...attrs}>An application on your device</span>
return <span {...attrs}>{loopbackClientName}</span>
}

if (isOAuthClientIdDiscoverable(clientId)) {
if (clientMetadata.client_name) {
return (
<span {...attrs}>
{clientMetadata.client_name} (
<UrlViewer url={clientId} path />)
</span>
)
}

return <UrlViewer {...attrs} url={clientId} path />
}

return <span {...attrs}>{clientMetadata.client_name || clientId}</span>
return <span {...attrs}>{clientId}</span>
}