본문으로 건너뛰기
Skillpedia
보안25k · #10089

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가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/nocobase/nocobase/blob/v3-develop/packages/plugins/app-plugin-authentication/skills/nocobase-app-plugin-authentication/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

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:

  • authenticationToken resolves the Auth instance: required(), optional(), getSession(headers), handler(request), signInUser(userId, request).
  • AuthEnv types a Hono router whose routes read context.get('auth').
  • userAdministrationServiceToken resolves UserAdministrationService: list, get, create, update, disable, enable, resetPassword, revokeSessions, withConnection; errors are UserAdministrationError.
  • AuthConfig is Better Auth's BetterAuthOptions, the type of the application's server/config/auth.ts. User initialization configuration lives separately under users.initialAdmin.
  • createAuthentication, databaseAdapter, createAuthStorage build 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, and AuthenticationGuard({ mode }) gate a route subtree on the session.
  • AuthConfig is Better Auth's client options, the type of the application's client/config/auth.ts.
  • authenticationClientToken is 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.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬