Files
cinny/src/app/pages/auth/login/OidcLogin.tsx
T
Lotus CIandClaude Opus 5.5 3c3bb2e41c
CI / Build & Quality Checks (push) Skipped
CI / Secret scan (gitleaks) (push) Skipped
CI / Playwright smoke (e2e) (push) Skipped
CI / Build & Quality Checks (pull_request) Successful in 3m41s
CI / Trigger Desktop Build (pull_request) Skipped
CI / Docker image build & smoke test (pull_request) Skipped
CI / Secret scan (gitleaks) (pull_request) Successful in 10s
CI / Playwright smoke (e2e) (pull_request) Successful in 16m45s
feat(auth): offer native OAuth sign-in on servers like matrix.org
The login page looked for an OAuth issuer in .well-known
(m.authentication), which matrix.org no longer publishes, so its users
got the password / SSO compatibility forms. Detect native OAuth the way
the SDK finds the auth server for refresh: load /auth_metadata next to
the login flows. When present:
- Login shows "Continue with <server>" only (as Element does); a legacy
  SSO loginToken coming back from a redirect still completes.
- Register opens the auth server's sign-up page (prompt=create, where
  prompt_values_supported says so) instead of the legacy forms.
Servers without it (Lotus) are unchanged.

Checked against the live servers: matrix.org login and register show
"Continue with matrix.org" and no password form; matrix.lotusguild.org
keeps its password form.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
2026-10-24 16:15:24 -04:00

52 lines
1.8 KiB
TypeScript

import { Box, Button, Spinner, Text, color } from 'folds';
import React, { useCallback } from 'react';
import { AsyncStatus, useAsyncCallback } from '../../../hooks/useAsyncCallback';
import { startOidcLogin } from '../oidc/oidcLoginUtil';
type OidcLoginProps = {
/** Register: open the auth server's sign-up page. */
register?: boolean;
homeserverBaseUrl: string;
serverName: string;
};
/**
* Native next-gen-auth (MSC3861/MSC2965) login button. Discovers + registers
* with the homeserver's OIDC provider and redirects to it. Mirrors `SSOLogin`'s
* single-button styling.
*/
export function OidcLogin({ homeserverBaseUrl, serverName, register }: OidcLoginProps) {
const [state, startLogin] = useAsyncCallback<void, unknown, Parameters<typeof startOidcLogin>>(
useCallback(startOidcLogin, []),
);
// Loading = discovering/registering; Success = redirect issued (page is leaving) —
// keep the button busy in both cases.
const ongoing = state.status === AsyncStatus.Loading || state.status === AsyncStatus.Success;
return (
<Box direction="Column" gap="300">
{state.status === AsyncStatus.Error && (
<Text size="T200" align="Center" style={{ color: color.Critical.Main }}>
{register
? 'Failed to open sign-up. Please try again.'
: 'Failed to start single sign-on. Please try again.'}
</Text>
)}
<Button
style={{ width: '100%' }}
size="500"
variant="Secondary"
fill="Soft"
outlined
onClick={() => startLogin(homeserverBaseUrl, register ? 'create' : undefined)}
disabled={ongoing}
before={ongoing ? <Spinner size="200" variant="Secondary" /> : undefined}
>
<Text align="Center" size="B500" truncate>
{`Continue with ${serverName}`}
</Text>
</Button>
</Box>
);
}