mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-27 21:01:03 +08:00
<!--
Make sure you've read the CONTRIBUTING.md guidelines:
https://github.com/stack-auth/stack-auth/blob/dev/CONTRIBUTING.md
-->
<!-- ELLIPSIS_HIDDEN -->
----
> [!IMPORTANT]
> Add admin-only API endpoints and UI support for project configuration
overrides, with comprehensive tests and documentation updates.
>
> - **New Features**:
> - Added admin-only API endpoints for reading and updating project
configuration overrides in `config/crud.tsx` and
`config/override/crud.tsx`.
> - Admin app supports fetching, caching, and updating configuration
overrides with new React hooks in `admin-app-impl.ts`.
> - **Bug Fixes**:
> - Validation and error handling for OAuth providers, duplicate IDs,
and invalid config fields in `oauth-providers/crud.tsx`.
> - **Tests**:
> - Added end-to-end tests for configuration management and validation
errors in `config.test.ts` and `js/config.test.ts`.
> - **Documentation**:
> - Updated API documentation for new config override endpoints in
`config.ts`.
>
> <sup>This description was created by </sup>[<img alt="Ellipsis"
src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=stack-auth%2Fstack-auth&utm_source=github&utm_medium=referral)<sup>
for 3d20abc092. You can
[customize](https://app.ellipsis.dev/stack-auth/settings/summaries) this
summary. It will automatically update as commits are pushed.</sup>
----
<!-- ELLIPSIS_HIDDEN -->
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Added the ability for admins to view and update project configuration
overrides through new internal API endpoints.
* Extended the admin app to support fetching, updating, and caching
configuration overrides, including React hook support for real-time
config usage.
* Introduced new admin interface methods for retrieving and updating
configuration.
* **Bug Fixes**
* Improved validation and error handling for configuration updates,
including checks for duplicate or invalid OAuth provider entries and
non-existent configuration fields.
* **Tests**
* Added comprehensive end-to-end tests covering configuration retrieval,
updates, access control, OAuth provider management, and domain
management.
* **Documentation**
* Enhanced API documentation for configuration management endpoints and
operations.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: Konsti Wohlwend <n2d4xc@gmail.com>
65 lines
1.8 KiB
TypeScript
65 lines
1.8 KiB
TypeScript
import { pick } from "@stackframe/stack-shared/dist/utils/objects";
|
|
import { it } from "../helpers";
|
|
import { createApp } from "./js-helpers";
|
|
|
|
it("gets config", async ({ expect }) => {
|
|
const { adminApp } = await createApp();
|
|
const project = await adminApp.getProject();
|
|
const config = await project.getConfig();
|
|
expect(pick(config, ["auth", "users", "teams"])).toMatchInlineSnapshot(`
|
|
{
|
|
"auth": {
|
|
"allowSignUp": true,
|
|
"oauth": {
|
|
"accountMergeStrategy": "link_method",
|
|
"providers": {},
|
|
},
|
|
"otp": { "allowSignIn": false },
|
|
"passkey": { "allowSignIn": false },
|
|
"password": { "allowSignIn": true },
|
|
},
|
|
"teams": {
|
|
"allowClientTeamCreation": false,
|
|
"createPersonalTeamOnSignUp": false,
|
|
},
|
|
"users": { "allowClientUserDeletion": false },
|
|
}
|
|
`);
|
|
});
|
|
|
|
it("updates config", async ({ expect }) => {
|
|
const { adminApp } = await createApp();
|
|
const project = await adminApp.getProject();
|
|
const config = await project.getConfig();
|
|
expect(config['auth']).toMatchInlineSnapshot(`
|
|
{
|
|
"allowSignUp": true,
|
|
"oauth": {
|
|
"accountMergeStrategy": "link_method",
|
|
"providers": {},
|
|
},
|
|
"otp": { "allowSignIn": false },
|
|
"passkey": { "allowSignIn": false },
|
|
"password": { "allowSignIn": true },
|
|
}
|
|
`);
|
|
|
|
await project.updateConfig({
|
|
'auth.allowSignUp': false,
|
|
});
|
|
|
|
const config2 = await project.getConfig();
|
|
expect(config2['auth']).toMatchInlineSnapshot(`
|
|
{
|
|
"allowSignUp": false,
|
|
"oauth": {
|
|
"accountMergeStrategy": "link_method",
|
|
"providers": {},
|
|
},
|
|
"otp": { "allowSignIn": false },
|
|
"passkey": { "allowSignIn": false },
|
|
"password": { "allowSignIn": true },
|
|
}
|
|
`);
|
|
});
|