next-auth README

The project's README from github.com/nextauthjs/next-auth. As one markdown file: README.md.


Auth.js

Authentication for the Web.

Open Source. Full Stack. Own Your Data.

X (formerly known Twitter) NPM next-auth@latest release Downloads GitHub Stars TypeScript

Auth.js is a set of open-source packages that are built on standard Web APIs for authentication in modern applications with any framework on any platform in any JS runtime.

Auth js is now part of Better Auth. We recommend new projects to start with Better Auth unless there are some very specific feature gaps (most notably stateless session management without a database).

Features

Flexible and easy to use

Own your data

Auth.js can be used with or without a database.

Secure by default

Advanced configuration allows you to define your routines to handle controlling what accounts are allowed to sign in, for encoding and decoding JSON Web Tokens and to set custom cookie security policies and session properties, so you can control who can sign in and how often sessions have to be re-validated.

TypeScript

Auth.js libraries are written with type safety in mind. Check out the docs for more information.

Security

If you think you have found a vulnerability (or are not sure) in Auth.js or any of the related packages (i.e. Adapters), we ask you to read our Security Policy to reach out responsibly. Please do not open Pull Requests/Issues/Discussions before consulting with us.

Acknowledgments

Auth.js is made possible thanks to all of its contributors.

Contributing

We're open to all community contributions! If you'd like to contribute in any way, please first read our Contributing Guide.

License

ISC

next-auth (nextauthjs/next-auth)

Searching Database…

28.4K ·GitHub
这是什么?Auth.js(next-auth 项目)是一套开源包,用于给 Web 应用添加身份验证。它基于标准 Web API 构建,可以在任何 JS 运行时中配合任何框架使用。
这是一个我要装进自己应用里的库,还是一个需要注册使用的托管服务?你把它安装到自己的应用里——身份验证逻辑在你自己的运行环境(Docker、Node.js、Serverless)中运行,中间没有任何外部托管服务。
我该怎么把它加到我的项目里?先用 npm install next-auth 安装这个包,然后按照 authjs.dev 文档中对应框架的快速上手指南操作——指南覆盖了 Next.js、Nuxt、SvelteKit、Solid 和 Remix 的配置方法。
我需要为它配置数据库才能用吗?不需要——用不用数据库都可以:内置支持 MySQL、MariaDB、Postgres、Microsoft SQL Server、MongoDB、SQLite、GraphQL 等,也可以完全无状态地对任意后端(比如 Active Directory 或 LDAP)做身份验证。
README 里提到了 Better Auth,那我还该用这个项目启动新项目吗?Auth.js 现在已并入 Better Auth,README 建议新项目直接用 Better Auth,除非存在特定的功能缺口——其中最突出的就是无需数据库的无状态会话管理,这仍然是本项目的独门优势。
我的用户数据会怎样——会有数据离开我的应用吗?不会向第三方发送任何东西:这是一个开源方案,设计初衷就是让你自己掌控数据,所有身份验证都完全在你的应用内部完成。
它开箱支持哪些登录方式?支持 OAuth 2.0+ 和 OIDC,内置对接很多常用的登录服务,还支持邮箱/免密码登录以及 Passkeys/WebAuthn。
不做额外配置的话,它在安全方面默认做了哪些防护?它默认就是安全的:登录、登出等 POST 路由带有 CSRF 令牌,采用严格的 Cookie 策略,JWT 默认以 JWE 格式用 A256CBC-HS512 加密,此外还有会话轮询和多标签页同步来保障短期会话,遵循 OWASP 的安全建议。
我能控制谁可以登录,以及会话的行为方式吗?可以——通过高级配置,你可以定义例程来控制哪些账号能登录、自定义 JWT 的编码和解码、自定义 Cookie 安全策略,以及会话的相关属性,比如会话需要多久重新验证一次。
使用它的时候有 TypeScript 类型吗?有——Auth.js 的库在编写时就充分考虑了类型安全;文档里介绍了带类型的配置细节。
Creator
nextauthjs
Size
68.9 MB
Stars
28.4K
Age
8y
Commits · 90 Days