Skip to content
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
22 changes: 22 additions & 0 deletions .changeset/33358-sign-in-floor-local-off-and-blocked-door.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
'@objectstack/plugin-auth': patch
'@object-ui/console': patch
'@object-ui/i18n': patch
'@object-ui/auth': patch
---

fix(plugin-auth)!: under the local sign-in path `off`, the auth settings save keeps a way to sign in, and a client the IP allow-list refuses at the direct sign-in door lands on the sign-in page

Clause-②: yes (narrowing) — narrowed: with direct sign-in on and its local sign-in path `off` (`directSignIn.localSignIn: 'off'`, or `OS_AUTH_DIRECT_SIGN_IN_LOCAL_PATH=off`), an auth settings save (`PUT /api/settings/auth`) that turns Google off, or clears a Google client credential no environment variable backs, while Google is the last way in the sign-in page offers answers `400 SETTINGS_VALIDATION` with the new copy `googleLocalOff` and saves nothing, where it saved, even with email and password (or phone sign-in) switched on; and a `GET /api/v1/auth/sign-in/direct` from a client the IP allow-list refuses answers `302` to the Console's `/login?error=IP_NOT_ALLOWED` (keeping a same-origin `?redirect=`), where it answered the `403 IP_NOT_ALLOWED` JSON body. Widened: under `off` with nothing else in force (no Google, no identity provider row, no social or OIDC provider with credentials, no host sign-in handoff), a save of `email_password_enabled: false` answers `200` and saves, where it answered `400 SETTINGS_VALIDATION`, because the sign-in page offers no email and password there either way; module exports (not on the package entry) `DIRECT_SIGN_IN_NETWORK_REFUSED`, `isDirectSignInDoorNavigation` and `directSignInNetworkRefusal`; a `googleLocalOff` key on the sign-in floor copy, in all 11 locales; the `@object-ui/i18n` key `auth.login.errors.networkNotAllowed`, in all 11 shipped locales (no key renamed or removed); the Console sign-in page explains `?error=IP_NOT_ALLOWED`; `markSignOutRoundTrip` in `@object-ui/auth` takes the sign-in page path it records.
Metadata-protocol: none
Skills-docs: none — no skill under `skills/**` teaches direct sign-in, the auth settings save, the IP allow-list or the sign-out note; `content/docs/permissions/sso.mdx` gains the rules in this change.

<!-- adr-0087: not-required (no-migration-prescription) No schema key, accepted value or metadata type is added, removed, renamed or re-shaped. The moved answers are a runtime refusal of one settings save under a deployment switch and the status of one refused auth navigation, so there is nothing stored for a migration to rewrite and no tombstone. -->

**BREAKING** for a deployment running direct sign-in with the local sign-in path `off`: saving the auth settings with Google off (or with an unbacked Google client credential cleared) while Google is the last way in the sign-in page offers is refused `400 SETTINGS_VALIDATION` and nothing is saved, unless another way in the page offers remains (another identity provider row, a social or OIDC provider with a client ID and secret, or a host sign-in handoff). Email and password and phone sign-in do not count there, because the page does not offer them; turning email and password on in the same save does not help. Before, the save went through and the sign-in page then showed "No sign-in method is available". Also **BREAKING** for anything that reads the status of `GET /api/v1/auth/sign-in/direct` from a client outside the IP allow-list: it is now `302` to `/login?error=IP_NOT_ALLOWED` with no cookie set, instead of the `403` JSON body.

Unchanged: the local sign-in path `hidden` (the default) and direct sign-in off, where email and password and phone sign-in count as before; the IP allow-list itself, which does not exempt the door: nothing is started and no provider is read for a refused client, every other auth request from it (including a `POST` to the door and the door path with a trailing slash) is still refused `403 IP_NOT_ALLOWED`, and the refusal is still audited and logged.

What to do: nothing, unless you turn Google off as the last way in under `off`, or switch email and password off there. Register another identity provider first, or set `OS_AUTH_DIRECT_SIGN_IN_LOCAL_PATH=hidden` (with email and password sign-in on) and restart. If email and password sign-in was switched off under `off` (that save is no longer refused), setting the local path back to `hidden` is not enough: set `OS_AUTH_EMAIL_PASSWORD_ENABLED=true` as well, then restart. A client that checked the door's `403` status should check for the `302` to `/login?error=IP_NOT_ALLOWED` instead.

Also fixed: the `503` sentence for a provider delete whose provider list could not be read now says the sign-in page offers no email and password, which is true under both reasons the check runs; and the note a provider-logout sign-out leaves in the tab now records the sign-in page the provider returns to, and only a load of that page reads it, so a provider that never sends the browser back no longer makes the next deep link opened in that tab drop its `?redirect=`.
30 changes: 21 additions & 9 deletions content/docs/permissions/sso.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -777,16 +777,21 @@ OAuth client's hand-off and when no provider can be started. It changes the
form only: `POST /api/v1/auth/sign-in/email` still accepts a password, and the
`/register` and `/forgot-password` pages are not changed by it.

Because the form then offers no email and password and no phone sign-in, two
checks that keep a way to sign in do not count them under `off`, even while
they are switched on: Setup's **Delete SSO Provider** on the last identity
provider is refused `409 DELETE_RESTRICTED` with nothing deleted, and a boot
with no identity provider reports at **error** under the grep token
`no_sign_in_method_at_boot`. Recover by setting
`OS_AUTH_DIRECT_SIGN_IN_LOCAL_PATH=hidden`, and
Because the form then offers no email and password and no phone sign-in, the
three checks that keep a way to sign in do not count them under `off`, even
while they are switched on. Saving the auth settings refuses a Google change
that removes the last way in (Google switched off, or a client credential
cleared that no environment variable backs) with `400 SETTINGS_VALIDATION`,
and turning email and password on in that save does not help. The email and
password switch itself is never refused under `off`, because the form draws it
neither way. Setup's **Delete SSO Provider** on the last identity provider is
refused `409 DELETE_RESTRICTED` with nothing deleted. A boot with no identity
provider reports at **error** under the grep token
`no_sign_in_method_at_boot`. Another identity provider, a social or OIDC
provider with a client ID and secret, or a host sign-in handoff still counts.
Recover by setting `OS_AUTH_DIRECT_SIGN_IN_LOCAL_PATH=hidden`, and
`OS_AUTH_EMAIL_PASSWORD_ENABLED=true` too when email and password sign-in is
off, then restarting. The auth settings save still counts email and password
under `off`; that check is still open.
off, then restarting.

**What a visit does.** The Console sign-in page reads `features.directSignIn`
from `GET /api/v1/auth/config`. That is `true` only while a provider can be
Expand Down Expand Up @@ -821,6 +826,13 @@ button (and the reason, where there is one), instead of starting again when:
starts from one address in a few seconds). It redirects to
`/login?error=direct_sign_in_rate_limited`, the page asks the visitor to
wait a few seconds and try again, and the `warn` line names `rate_limited`;
- the [IP allow-list](/docs/permissions/authentication) refuses the
visitor's network. The door is not exempt from the allow-list: a browser
`GET` of the door from a refused address starts nothing and is redirected
to `/login?error=IP_NOT_ALLOWED` (keeping a same-origin `?redirect=`)
instead of the `403` body, the page says sign-in is not allowed from this
network, and every other auth request from that address is still refused
`403 IP_NOT_ALLOWED`;
- the person just signed out in that tab. Often the identity provider's
session outlives the platform's, so starting again would sign them straight
back in. When the provider ends its own session too (an OIDC provider whose
Expand Down
16 changes: 15 additions & 1 deletion packages/plugins/plugin-auth/src/auth-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@ import { resolveKernelCache } from './kernel-cache.js';
import { authIdentityManifest } from './manifest.js';
import { scheduleLegacySsoSecretMigration } from './sso-client-secret.js';
import { reportSsoProvidersWithNonBareDomainEntries } from './sso-stored-domain-entries.js';
import type { DirectSignInOptions } from './direct-sign-in.js';
import {
directSignInNetworkRefusal,
isDirectSignInDoorNavigation,
type DirectSignInOptions,
} from './direct-sign-in.js';
import {
devSeedAdminEmail,
devSeedAdminPassword,
Expand Down Expand Up @@ -3880,6 +3884,9 @@ export class AuthPlugin implements Plugin {
// of the routes below. The public render helpers (/config,
// /bootstrap-status) are exempt so a blocked client still gets a clean
// login page + error. Nothing is judged when no ranges are configured.
// Direct sign-in's start door is NOT exempt: a blocked browser that
// navigated to it is refused with a landing on the sign-in page that names
// the refusal (`directSignInNetworkRefusal`), never by reaching the door.
//
// The address judged is the one the server ESTABLISHED, by the platform's
// client-address trust rule (`AuthManager.resolveClientAddress`, shared
Expand All @@ -3905,6 +3912,13 @@ export class AuthPlugin implements Plugin {
if (!mgr.isClientIpAllowed(ip)) {
this.explainAllowListRefusal(ctx, mgr, ip, headers);
this.auditAllowListRefusal(ctx, mgr, c, path.startsWith(basePath) ? path.slice(basePath.length) : path, ip);
if (
this.directSignInDoorMounted &&
typeof mgr.getConsoleUrl === 'function' &&
isDirectSignInDoorNavigation(c.req.method, path, basePath)
) {
return directSignInNetworkRefusal(c.req.url, (page) => mgr.getConsoleUrl(page));
}
return c.json(
{ success: false, error: { code: 'IP_NOT_ALLOWED', message: 'Sign-in is not allowed from your network.' } },
403,
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/plugin-auth/src/auth-route-ledger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export const AUTH_ROUTE_LEDGER: readonly AuthRouteLedgerEntry[] = [
// Direct sign-in's start door (`direct-sign-in.ts`): mounted only while the
// setting is on (the `directSignIn` option or OS_AUTH_DIRECT_SIGN_IN_ENABLED),
// so `requires` names that setting rather than a better-auth plugin.
{ route: 'GET /api/v1/auth/sign-in/direct', family: 'objectstack-mount', source: 'objectstack', disposition: 'public', requires: 'directSignIn', note: 'no SDK method builds this URL — the Console sign-in page navigates the browser here with ?callbackURL=<same-origin path> and no session; it starts the configured identity provider through the vendor start (/sign-in/social or /sign-in/sso) and answers 302 to it with the vendor state cookie, minting nothing; a return path that is not a same-origin path is dropped, and a start that cannot happen redirects to the sign-in page with error=direct_sign_in_unavailable (error=direct_sign_in_rate_limited when the vendor sign-in rate limit refused it)' },
{ route: 'GET /api/v1/auth/sign-in/direct', family: 'objectstack-mount', source: 'objectstack', disposition: 'public', requires: 'directSignIn', note: 'no SDK method builds this URL — the Console sign-in page navigates the browser here with ?callbackURL=<same-origin path> and no session; it starts the configured identity provider through the vendor start (/sign-in/social or /sign-in/sso) and answers 302 to it with the vendor state cookie, minting nothing; a return path that is not a same-origin path is dropped, and a start that cannot happen redirects to the sign-in page with error=direct_sign_in_unavailable (error=direct_sign_in_rate_limited when the vendor sign-in rate limit refused it); a client the IP allow-list refuses never reaches it and is redirected to the sign-in page with error=IP_NOT_ALLOWED instead of the 403 body' },
// #10974 / #10975 — the ninth ObjectStack mount from the #10534 census,
// ledgered `sdk` on the maintainer's option-C ruling (2026-08-22) rather
// than on either word that was available before it. The two halves landed
Expand Down
69 changes: 68 additions & 1 deletion packages/plugins/plugin-auth/src/direct-sign-in.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { repeatedQueryParamMessage, unknownQueryParamRefusalMessage } from '@obj
import { createMemoryEngine } from './impersonation-bearer-rotation.test';
import {
DIRECT_SIGN_IN_ENV,
DIRECT_SIGN_IN_NETWORK_REFUSED,
DIRECT_SIGN_IN_QUERY_PARAMS,
DIRECT_SIGN_IN_RATE_LIMITED,
DIRECT_SIGN_IN_UNAVAILABLE,
Expand Down Expand Up @@ -358,7 +359,7 @@ afterEach(() => {
}
});

function mount(directSignIn?: { provider?: string; localSignIn?: 'hidden' | 'off' }) {
function mount(directSignIn?: { provider?: string; localSignIn?: 'hidden' | 'off' }, extra: Record<string, unknown> = {}) {
const app = new Hono();
const ctx = {
registerService: vi.fn(),
Expand All @@ -384,6 +385,7 @@ function mount(directSignIn?: { provider?: string; localSignIn?: 'hidden' | 'off
},
],
...(directSignIn ? { directSignIn } : {}),
...extra,
};
const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
const plugin = new AuthPlugin(options as any);
Expand Down Expand Up @@ -452,6 +454,71 @@ describe('the mounted start door (setting on)', () => {
});
});

// ── The IP allow-list in front of the door (ADR-0069 D5) ─────────────────────

describe('a client the IP allow-list refuses lands on the sign-in page, and the door still starts nothing for it', () => {
/** Documentation ranges (RFC 5737): one allowed, one not. */
const RANGE = '203.0.113.0/24';
const INSIDE = '203.0.113.7';
const OUTSIDE = '198.51.100.9';
const fromPeer = (app: Hono, path: string, peer: string, init: RequestInit = {}) =>
app.request(`${ORIGIN}${path}`, init, { incoming: { socket: { remoteAddress: peer } } });
const DOOR = '/api/v1/auth/sign-in/direct';
const RETURN = `?callbackURL=${encodeURIComponent('/_console/login?redirect=%2Fapps%2Fcrm&direct=returned')}`;

it('a blocked navigation to the door answers 302 to /login?error=IP_NOT_ALLOWED with the page\'s ?redirect= kept, and no vendor state', async () => {
const { app } = mount({ provider: PLATFORM_IDP }, { allowedIpRanges: [RANGE] });
const res = await fromPeer(app, `${DOOR}${RETURN}`, OUTSIDE);
expect(res.status).toBe(302);
expect(res.headers.get('location')).toBe(
`${ORIGIN}/_console/login?error=${DIRECT_SIGN_IN_NETWORK_REFUSED}&redirect=%2Fapps%2Fcrm`,
);
expect(res.headers.getSetCookie()).toEqual([]);

// No ?redirect= on the page, or a foreign one: the bare landing with the code.
for (const query of ['', `?callbackURL=${encodeURIComponent('/_console/login?redirect=https%3A%2F%2Fevil.test')}`]) {
const bare = await fromPeer(app, `${DOOR}${query}`, OUTSIDE);
expect(bare.status).toBe(302);
expect(bare.headers.get('location')).toBe(`${ORIGIN}/_console/login?error=${DIRECT_SIGN_IN_NETWORK_REFUSED}`);
}
});

it('the page it lands on can still read /auth/config, which says direct sign-in is on, while every sign-in door stays refused 403', async () => {
const { app } = mount({ provider: PLATFORM_IDP }, { allowedIpRanges: [RANGE] });
const cfg = await fromPeer(app, '/api/v1/auth/config', OUTSIDE);
expect(cfg.status).toBe(200);
expect((await cfg.json()).data.features.directSignIn).toBe(true);
for (const [path, init] of [
['/api/v1/auth/get-session', {}],
['/api/v1/auth/sign-in/social', { method: 'POST', headers: { 'content-type': 'application/json', origin: ORIGIN }, body: JSON.stringify({ provider: PLATFORM_IDP }) }],
[DOOR, { method: 'POST' }],
// Only the door's exact path is the navigation that lands on the page: a trailing slash is not it.
[`${DOOR}/${RETURN}`, {}],
] as const) {
const res = await fromPeer(app, path, OUTSIDE, init as RequestInit);
expect(res.status, path).toBe(403);
expect((await res.json()).error.code, path).toBe('IP_NOT_ALLOWED');
}
});

it('CONTROL: an allowed client still starts the identity provider through the door', async () => {
const { app } = mount({ provider: PLATFORM_IDP }, { allowedIpRanges: [RANGE] });
const res = await fromPeer(app, `${DOOR}${RETURN}`, INSIDE);
expect(res.status).toBe(302);
const location = new URL(res.headers.get('location')!);
expect(`${location.origin}${location.pathname}`).toBe(`${IDP}/${PLATFORM_IDP}/authorize`);
expect(res.headers.getSetCookie().length).toBeGreaterThan(0);
});

it('CONTROL: with direct sign-in off (no door), the same blocked request is the 403 body as before', async () => {
const { app } = mount(undefined, { allowedIpRanges: [RANGE] });
const res = await fromPeer(app, `${DOOR}${RETURN}`, OUTSIDE);
expect(res.status).toBe(403);
expect((await res.json()).error.code).toBe('IP_NOT_ALLOWED');
expect(res.headers.get('location')).toBeNull();
});
});

describe('CONTROL: with the setting off, the door and /auth/config are what they are on main', () => {
it('does not mount the door: the path answers what an unclaimed auth path answers', async () => {
const off = mount();
Expand Down
Loading
Loading