Skip to content

Commit 27c82ee

Browse files
committed
Merge branch 'main' into feat/popup-auth-preview-domains
2 parents 89ca60a + ead5bf3 commit 27c82ee

2 files changed

Lines changed: 21 additions & 8 deletions

File tree

src/modules/auth.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,19 @@ export function createAuthModule(
117117
// Build the full redirect URL
118118
const redirectUrl = new URL(fromUrl, window.location.origin).toString();
119119

120-
// Build the provider login URL (google is the default, so no provider path needed)
121-
const providerPath = provider === "google" ? "" : `/${provider}`;
122-
const loginUrl = `${
123-
options.appBaseUrl
124-
}/api/apps/auth${providerPath}/login?app_id=${appId}&from_url=${encodeURIComponent(
125-
redirectUrl
126-
)}`;
120+
const queryParams = `app_id=${appId}&from_url=${encodeURIComponent(redirectUrl)}`;
121+
122+
// SSO uses a different URL structure with appId in the path
123+
let authPath: string;
124+
if (provider === "sso") {
125+
authPath = `/apps/${appId}/auth/sso/login`;
126+
} else {
127+
// Google is the default provider, so no provider path segment needed
128+
const providerPath = provider === "google" ? "" : `/${provider}`;
129+
authPath = `/apps/auth${providerPath}/login`;
130+
}
131+
132+
const loginUrl = `${options.appBaseUrl}/api${authPath}?${queryParams}`;
127133

128134
// On preview/sandbox/checkpoint domains the app runs inside an iframe —
129135
// use a popup to avoid OAuth providers blocking iframe navigation.

src/modules/auth.types.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,9 @@ export interface AuthModule {
199199
* - `'microsoft'` - {@link https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-auth-code-flow | Microsoft OAuth}. Enable Microsoft in your app's authentication settings before specifying this provider.
200200
* - `'facebook'` - {@link https://developers.facebook.com/docs/facebook-login | Facebook Login}. Enable Facebook in your app's authentication settings before using.
201201
* - `'apple'` - {@link https://developer.apple.com/sign-in-with-apple/ | Sign in with Apple}. Enable Apple in your app's authentication settings before using this provider.
202+
* - `'sso'` - Enterprise SSO. Enable SSO in your app's authentication settings before using this provider.
202203
*
203-
* @param provider - The authentication provider to use: `'google'`, `'microsoft'`, `'facebook'`, or `'apple'`.
204+
* @param provider - The authentication provider to use: `'google'`, `'microsoft'`, `'facebook'`, `'apple'`, or `'sso'`.
204205
* @param fromUrl - URL to redirect to after successful authentication. Defaults to `'/'`.
205206
*
206207
* @example
@@ -220,6 +221,12 @@ export interface AuthModule {
220221
* // Apple
221222
* base44.auth.loginWithProvider('apple', '/dashboard');
222223
* ```
224+
*
225+
* @example
226+
* ```typescript
227+
* // SSO
228+
* base44.auth.loginWithProvider('sso', '/dashboard');
229+
* ```
223230
*/
224231
loginWithProvider(provider: string, fromUrl?: string): void;
225232

0 commit comments

Comments
 (0)