mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 21:15:32 +09:00
feat: use client-provided SSO redirectUri (#1155)
Co-authored-by: Hampus <[email protected]>
This commit is contained in:
1 parent
b80d41a7bf
commit
a45693f581
7 files changed
+92
-19
No files matched your search
@@ -16,6 +16,9 @@ import type {ValueOf} from '@fluxer/constants/src/ValueOf';
|
||||
import type {
|
||||
AuthRegistrationPendingApprovalResponse,
|
||||
RegisterRequest,
|
||||
SsoCompleteResponse,
|
||||
SsoStartRequest,
|
||||
SsoStartResponse,
|
||||
} from '@fluxer/schema/src/domains/auth/AuthSchemas';
|
||||
import type {UserPartial} from '@fluxer/schema/src/domains/user/UserResponseSchemas';
|
||||
import type {AuthenticationResponseJSON, PublicKeyCredentialRequestOptionsJSON} from '@simplewebauthn/browser';
|
||||
@@ -627,20 +630,26 @@ export async function completeLogin(
|
||||
}
|
||||
}
|
||||
|
||||
export async function startSso(redirectTo?: string): Promise<{
|
||||
authorization_url: string;
|
||||
}> {
|
||||
const response = await http.post<{
|
||||
authorization_url: string;
|
||||
}>(Endpoints.AUTH_SSO_START, {
|
||||
body: {redirect_to: redirectTo},
|
||||
export async function startSso({
|
||||
redirectTo,
|
||||
redirectUri,
|
||||
}: {
|
||||
redirectTo?: string;
|
||||
redirectUri?: string;
|
||||
} = {}): Promise<SsoStartResponse> {
|
||||
const body: SsoStartRequest = {
|
||||
redirect_to: redirectTo,
|
||||
redirect_uri: redirectUri,
|
||||
};
|
||||
const response = await http.post<SsoStartResponse>(Endpoints.AUTH_SSO_START, {
|
||||
body,
|
||||
headers: withPlatformHeader(),
|
||||
});
|
||||
return response.body;
|
||||
}
|
||||
|
||||
export async function completeSso({code, state}: {code: string; state: string}): Promise<TokenResponse> {
|
||||
const response = await http.post<TokenResponse>(Endpoints.AUTH_SSO_COMPLETE, {
|
||||
export async function completeSso({code, state}: {code: string; state: string}): Promise<SsoCompleteResponse> {
|
||||
const response = await http.post<SsoCompleteResponse>(Endpoints.AUTH_SSO_COMPLETE, {
|
||||
body: {code, state},
|
||||
headers: withPlatformHeader(),
|
||||
});
|
||||
|
||||
@@ -168,13 +168,17 @@ export function getPendingSsoRedirectTo(): string | undefined {
|
||||
}
|
||||
}
|
||||
|
||||
export async function startSsoLogin({redirectTo}: {redirectTo?: string}): Promise<{
|
||||
export async function startSsoLogin({redirectTo, redirectUri}: {redirectTo?: string; redirectUri?: string}): Promise<{
|
||||
authorizationUrl: string;
|
||||
redirectUri: string;
|
||||
}> {
|
||||
const safeRedirectTo = safeRedirectTarget(redirectTo);
|
||||
const result = await AuthenticationCommands.startSso(safeRedirectTo ?? undefined);
|
||||
const result = await AuthenticationCommands.startSso({
|
||||
redirectTo: safeRedirectTo ?? undefined,
|
||||
redirectUri,
|
||||
});
|
||||
storeSsoRedirectTo(safeRedirectTo ?? undefined);
|
||||
return {authorizationUrl: result.authorization_url};
|
||||
return {authorizationUrl: result.authorization_url, redirectUri: result.redirect_uri};
|
||||
}
|
||||
|
||||
export async function completeSsoLogin({code, state}: {code: string; state: string}): Promise<LoginSuccessPayload> {
|
||||
|
||||
Reference in new issue
Block a user