nocobase-app-plugin-authentication
できること
Better Authを使い、NocoBase 3アプリでサインインの状態に関する作業を案内します。ページの保護、ログインのカスタマイズ、サインイン方法の追加を行う開発者向けです。
使う場面
- ✓サインイン済みの利用者だけがAPIルートやページを使えるよう、保護する必要があるとき。
- ✓アプリにソーシャルログインやOIDCサインインを追加したいとき。
- ✓ログイン、登録、パスワードのページをカスタマイズしたいとき。
スキルのリンク
https://github.com/nocobase/nocobase/blob/v3-develop/packages/plugins/app-plugin-authentication/skills/nocobase-app-plugin-authentication/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“私のNocoBaseアプリにGoogleサインインを追加し、管理ページにはサインイン済みの利用者だけが入れるようにしてください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
AIはBetter Authの設定でサインイン方法を追加し、セッションを使ってルートを保護します。必要に応じてサインインのページをカスタマイズします。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Authentication development
Use this Skill when an application built on @nocobase/app-plugin-authentication
needs anything about who the caller is: protecting a route or page, reading the
current user, changing the sign-in pages, adding a sign-in method, disabling
accounts, or preparing authentication for deployment.
Do not use it for what a signed-in user may do — that is
nocobase-app-plugin-authorization — or for the user administration page,
which is nocobase-app-plugin-users. Do not modify the plugin's own source,
migrations, or dist/; everything below is done in the application.
The plugin wraps Better Auth. Application configuration is Better Auth configuration, and every Better Auth plugin, social provider, and hook is available through it. Read the installed Better Auth version's documentation for option details; this Skill covers where those options go in a NocoBase application and what the plugin adds on top.
Enable an official Better Auth plugin before writing anything of your own: device login for a CLI (deviceAuthorization() with bearer()), organizations, two-factor and passkeys all exist upstream, and each needs only configuration, an application migration for its tables, and its UI. Enabling an official Better Auth plugin covers the rule, the schema check and the migration.
Public surfaces
Server, from @nocobase/app-plugin-authentication (the root entry is the
server entry) or @nocobase/app-plugin-authentication/server:
authenticationTokenresolves theAuthinstance:required(),optional(),getSession(headers),handler(request),signInUser(userId, request).AuthEnvtypes a Hono router whose routes readcontext.get('auth').userAdministrationServiceTokenresolvesUserAdministrationService:list,get,create,update,disable,enable,resetPassword,revokeSessions,withConnection; errors areUserAdministrationError.AuthConfigis Better Auth'sBetterAuthOptions, the type of the application'sserver/config/auth.ts. User initialization configuration lives separately underusers.initialAdmin.createAuthentication,databaseAdapter,createAuthStoragebuild an instance outside the application runtime, mainly in tests.
Client, from @nocobase/app-plugin-authentication/client:
authentication()is the registration factory. It takes no options, contributes no routes, and mounts one React provider.useAuthentication()returns{ client, session, isPending, refresh };useAuthenticationClient()returns the Better Auth client alone.RequiredAuthentication,GuestAuthentication, andAuthenticationGuard({ mode })gate a route subtree on the session.AuthConfigis Better Auth's client options, the type of the application'sclient/config/auth.ts.authenticationClientTokenis the client's service token, used to stub the client in component tests.
Headless actions, from @nocobase/app-plugin-authentication/client/actions:
usePasswordLogin, usePasswordRegistration, usePasswordResetRequest,
usePasswordReset, each returning { submit, isPending, error }.
HTTP: every Better Auth endpoint is served under /api/auth/* by the plugin's
own route. A Better Auth plugin's endpoints appear there automatically. There
is no other authentication REST surface.
API document: the plugin lets a signed-in session read the App's OpenAPI document at GET /api/swagger and its Swagger UI at GET /api/swagger/docs; an anonymous request gets 401 with error.reason API_DOCS_UNAUTHENTICATED, and @nocobase/app-plugin-api-keys adds API keys as a second way in. The plugin also merges Better Auth's endpoints into that document from Better Auth's own OpenAPI generator, at their full /api/auth/... paths and tagged Authentication, so a Better Auth plugin added to auth.plugins is documented without further work. Browser-only steps are left out: /sign-in/social, /link-social, /callback/{id}, /verify-email, /reset-password/{token}, /delete-user/callback and /error. Do not add Better Auth's openAPI() plugin: it would publish its own unauthenticated /api/auth/reference page and schema route.
Choose the task path
| The task is | Read | | ---------------------------------------------------
よくある質問
このスキルは、利用者ができることを決めますか?
いいえ。サインイン後に何をできるかは、認可のスキルの担当です。
二段階認証やパスキーを追加できますか?
はい。二段階認証やパスキーなど、Better Authの公式プラグインの有効化を扱います。
プラグイン自体のコードを変えますか?
いいえ。すべての変更は、あなたのアプリケーションに書き込みます。
詳細
作者による元の説明
Build authentication requirements in a NocoBase 3 application: protect API routes and pages with the session, read and refresh the session in the browser, customize the login, registration and password pages, add sign-in methods such as social login, OIDC or a custom Better Auth plugin, enable official Better Auth plugins (device login for a CLI, bearer tokens, organizations, two-factor, passkeys) with the migration their tables need, manage account lifecycle from server code, and configure secrets, cookies and shared storage for deployment.
repo: nocobase/nocobase
人気
- GitHubのスター
- 25k
- ランキング
- #10089
- ライセンス
- —
- 更新日
- 2026/11/2
コメント
- …
このリポジトリの他のスキル
nocobase-app-development
25kエージェントが、NocoBase 3の完全なビジネスアプリケーションのために、ページ、ルーティング、データ、権限、テストを作れるよう支援します。
shadcn
25kエージェントが、公式のドキュメントとレジストリを使い、Webプロジェクトの shadcn/uiコンポーネントを見つけ、追加し、修正し、スタイルを整えられるよう支援します。
nocobase-app-plugin-development
25kエージェントが、既存のNocoBase 3アプリの中で、サーバー、クライアント、データベース、登録の部分を含むプラグインを作成し、保守できるよう支援します。
nocobase-app-upgrade
25kエージェントが、NocoBaseのアプリを新しいテンプレートのリリースにアップグレードし、テンプレートの変更を取り込みつつ、あなた自身の作業を保てるよう支援します。
似ているスキル
reverse-engineer-anything
422kREAツールを使って、出荷済みのアプリやパッケージの中身を調べ、機能の説明、版の比較、再構築の手順をエージェントが支援します。
1password
394k1Password CLIをセットアップし、サインインして、秘密情報の値を会話に表示せずに読み取ったり注入したりするようエージェントを支援します。
healthcheck
394kOpenClawを動かすコンピューターやサーバーを、SSH、ファイアウォール、更新、バックアップなどのセキュリティリスクについて監査し、安全な修正案を提案するようエージェントを支援します。