开源的用户管理解决方案,自带前端组件和管理后台。
Go to file
Zai Shi e5965cf977
Team frontend components (#178)
* Team invitation (#171)

* team invitation wip

* implemented handler

* team invitation callback wip

* added team invitation frontend

* fixed listCurrentUserTeamPermissions

* added team invitation email template

* fixed bugs

* fixed verification code handler

* added more checks to team invitation verification

* fixed team invitation page

* restructured verification code handler

* fixed frontend

* fixed team invitation tests

* added more team invitation test

* fixed bug

* added migration file

* removed unused code

* Allow Next.js version `latest` in package.json

* Fix typo

* Update error message

* Remove unnecessary console.warn

* Updated "edit this page" button

* Hide unsupported properties from docs

* OAuth token tests

* Fix typo

* added create user button

* added create user button (#173)

* added basic team settings

* Create SECURITY.md

* added editable text

* added more team settings

* Export button in tables

* Export all pages of tables

* Update security policy

* Fix docs typo

* More docs typos

* Improved user creation handlers

* added list users on client

* updated team-settings

* hide team setting component for now

* Fix: Improve error handling for Server API (#170)

* Added entity checks to provide better errors in API for 'server' access type

* Removed 'ensureUserTeamPermissionExist', changed permissionId type to string in 'ensureUserHasTeamPermission'

* added different error types for user team permission

---------

Co-authored-by: Fahad Khan <fahad.khan@net-mon.net>
Co-authored-by: Zai Shi <zaishi00@outlook.com>

* added ensureClientUserAuthenticated

* improved error handling

* removed unused imports

* fixed bug

* added member list

* Sign up restriction button on dashboard

Fix #66, #74

* moved data table to stack-ui

* added remove user modal

* fixed chokidar

* updated ui

* fixed merge

* fixed merge

* fixed merge

* updated settings component

* improved mobile styles

* added user invitation ui

* added team creation page

* added team creation to team component

* added setting icon to team switcher

* added settings sections

* added client_team_creation_enabled

* added frontend team creation enabled checks

* updated demo page

* added member profile update

* fixed profile editing

* added leave team button

* added create/delete team redirect

* fixed column header, updated team setting

* fixed account setting padding

* updated tests

---------

Co-authored-by: Stan Wohlwend <n2d4xc@gmail.com>
Co-authored-by: Fahad Khan <62707456+kfahad5607@users.noreply.github.com>
Co-authored-by: Fahad Khan <fahad.khan@net-mon.net>
2024-08-12 02:11:42 +02:00
.changeset chore: update package versions 2024-06-07 13:32:12 +02:00
.github Sign up restriction button on dashboard 2024-08-10 09:45:48 -07:00
.vscode TOTP MFA components 2024-08-10 09:45:49 -07:00
apps Team frontend components (#178) 2024-08-12 02:11:42 +02:00
docs chore: update package versions 2024-08-10 09:45:49 -07:00
eslint-configs New client (#135) 2024-07-19 22:07:44 -07:00
examples Team frontend components (#178) 2024-08-12 02:11:42 +02:00
packages Team frontend components (#178) 2024-08-12 02:11:42 +02:00
.gitignore Add generated tsup cache files to .gitignore 2024-08-10 17:03:06 -07:00
CONTRIBUTING.md Update CONTRIBUTING.md 2024-08-04 12:34:15 -07:00
dependencies.compose.yaml Webhooks (#157) 2024-08-01 02:44:35 +02:00
LICENSE Update license files 2024-05-04 15:52:49 +02:00
package.json Mock OAuth server (#138) 2024-07-20 17:29:04 -07:00
pnpm-lock.yaml Team frontend components (#178) 2024-08-12 02:11:42 +02:00
pnpm-workspace.yaml Move examples to their own folder (#77) 2024-06-16 14:58:10 +02:00
README.md Update README 2024-08-02 16:45:42 -07:00
turbo.json Fix type error 2024-08-10 09:45:48 -07:00
vercel.json Increase function timeout 2024-04-21 16:47:23 +02:00
vitest.workspace.ts Create users & auth endpoints in backend (#85) 2024-07-01 22:42:08 -07:00

Stack Logo

📘 Docs | ☁️ Hosted Version | Demo | 🎮 Discord

Stack Auth: Open-source Clerk/Auth0 alternative

Stack Auth is a managed user authentication solution. It is developer-friendly and fully open-source (licensed under MIT and AGPL).

Stack gets you started in just five minutes, after which you'll be ready to use all of its features as you grow your project. Our managed service is completely optional and you can export your user data and self-host, for free, at any time.

We support Next.js frontends, along with any backend that can use our REST API. Check out our setup guide to get started.

Stack Setup

Table of contents

How is this different from X?

Ask yourself about X:

  • Is X open-source?
  • Is X developer-friendly, well-documented, and lets you get started in minutes?
  • Besides authentication, does X also do authorization and user management (see feature list below)?

If you answered "no" to any of these questions, then that's how Stack Auth is different from X.

Features

<SignIn/> and <SignUp/>

Authentication components that support OAuth, password credentials, and magic links, with shared development keys to make setup faster. All components support dark/light modes.
Sign-in component

Idiomatic Next.js APIs

We build on server components, React hooks, and route handlers.
Dark/light mode

User dashboard

Dashboard to filter, analyze, and edit users. Replaces the first internal tool you would have to build.
User dashboard

Account settings

Lets users update their profile, verify their e-mail, or change their password. No setup required.
Account settings component

Multi-tenancy & teams

Manage B2B customers with an organization structure that makes sense and scales to millions.
Selected team switcher component

Role-based access control

Define an arbitrary permission graph and assign it to users. Organizations can create org-specific roles.
RBAC

OAuth Connections

Beyond login, Stack can also manage access tokens for third-party APIs, such as Outlook and Google Calendar. It handles refreshing tokens and controlling scope, making access tokens accessible via a single function call.
OAuth tokens

Impersonation

Impersonate users for debugging and support, logging into their account as if you were them.
Webhooks

Webhooks

Get notified when users use your product, built on Svix.
Webhooks

Automatic emails

Send customizable emails on triggers such as sign-up, password reset, and email verification, editable with a WYSIWYG editor.
Email templates

User session & JWT handling

Stack manages refresh and access tokens, JWTs, and cookies, resulting in the best performance at no implementation cost.
User button

M2M authentication

Use short-lived access tokens to authenticate your machines to other machines.
M2M authentication

📦 Installation & Setup

Refer to our documentation on how to set up Stack Auth in your Next.js project.

🌱 Some community projects built with Stack

Have your own? Happy to feature it if you create a PR or message us on Discord.

Templates

Examples

🏗️ Development & Contribution

This is for you if you want to contribute to the Stack project or run the Stack dashboard locally.

Important: Please read the contribution guidelines carefully and join our Discord if you'd like to help.

Requirements

  • Node v20
  • pnpm v9
  • Docker

Setup

Pre-populated .env files for the setup below are available and used by default in .env.development in each of the packages. You should copy all the .env.development files to .env.local in the respective packages for local development.

In a terminal, start the dependencies (Postgres and Inbucket) as Docker containers:

docker compose -f dependencies.compose.yaml up

Then open a new terminal:

pnpm install

# Run build to build everything once
pnpm run build

# initialize the database and seed it with some data
pnpm prisma db push
pnpm prisma db seed

# Run code generation (repeat this after eg. changing the Prisma schema). This is part of the build script, but faster
pnpm run codegen

# Start the dev server
pnpm run dev

# In a different terminal, run tests in watch mode
pnpm run test

You can now open the dashboard at http://localhost:8101, API on port 8102, demo on port 8103, docs on port 8104, Inbucket (e-mails) on port 8105, and Prisma Studio on port 8106.

Your IDE may show an error on all @stackframe/XYZ imports. To fix this, simply restart the TypeScript language server; for example, in VSCode you can open the command palette (Ctrl+Shift+P) and run Developer: Reload Window or TypeScript: Restart TS server.

You can also open Prisma Studio to see the database interface and edit data directly:

pnpm run prisma studio

Database migrations

If you make changes to the Prisma schema, you need to run the following command to create a migration:

pnpm run prisma migrate dev

❤️ Contributors

Thanks to the amazing community who built Stack: