Agent Skillsmx-space/core › mx-core-local-auth

mx-core-local-auth

GitHub

在本地开发环境中,当UI或API验证遇到登录门控时,通过操作PostgreSQL数据库创建临时的所有者会话以绕过认证,并在验证完成后立即清理。

.claude/skills/mx-core-local-auth/SKILL.md mx-space/core

Trigger Scenarios

UI或API验证遇到401或AUTH_NOT_LOGGED_IN响应 需要绕过本地开发环境的登录门控进行功能测试

Install

npx skills add mx-space/core --skill mx-core-local-auth -g -y
More Options

Non-standard path

npx skills add https://github.com/mx-space/core/tree/master/.claude/skills/mx-core-local-auth -g -y

Use without installing

npx skills use mx-space/core@mx-core-local-auth

指定 Agent (Claude Code)

npx skills add mx-space/core --skill mx-core-local-auth -a claude-code -g -y

安装 repo 全部 skill

npx skills add mx-space/core --all -g -y

预览 repo 内 skill

npx skills add mx-space/core --list

SKILL.md

Frontmatter
{
    "name": "mx-core-local-auth",
    "description": "Create and reuse a short-lived local mx-core owner session when UI or API verification encounters a login gate, redirect, 401, or AUTH_NOT_LOGGED_IN response. Use only against the local development database and remove the temporary session after verification."
}

Local authentication during verification

Treat authentication as an on-demand branch of the verification being performed.

  1. Attempt the exact UI or API operation that needs verification.
  2. If it succeeds anonymously, continue without creating authentication state.
  3. If it fails on authentication, create one short-lived owner session directly in the local PostgreSQL sessions table.
  4. Reuse that session for the original operation, collect the required evidence, and delete the session immediately afterward.

Create the temporary session

Use the repository's configured local PG_URL; do not assume a container name or hard-code database credentials. Generate a unique session ID and a high-entropy token without a . character. Insert a session that expires in at most 15 minutes:

WITH target AS (
  SELECT r.id, a.provider_id
  FROM readers AS r
  JOIN accounts AS a ON a.user_id = r.id
  WHERE r.role = 'owner'
  ORDER BY r.created_at
  LIMIT 1
)
INSERT INTO sessions (id, user_id, token, expires_at, provider)
SELECT '<session-id>', id, '<session-token>', now() + interval '15 minutes', provider_id
FROM target;

Fail if no owner account was selected or the insert did not create exactly one row. Do not create or modify a reader, account, password, or API key.

Reuse the session

  • For API verification, send the raw token as Authorization: Bearer <session-token>. The enabled Better Auth bearer() plugin signs it internally and resolves the matching database session.
  • For browser UI verification, sign the token with the local JWT_SECRET using HMAC-SHA256 with standard Base64 output, then set better-auth.session_token=<token>.<signature> in the same browser context used for evidence. Let the browser cookie API encode the value; when writing a raw Cookie header, URL-encode it first. Never print the secret, token, or cookie.

Retry the exact protected operation rather than adding a separate authentication test. Local development routes have no /api/v1 prefix.

Cleanup and boundaries

Delete the temporary row by both ID and token in a finally-style cleanup, even when verification fails. This workflow is forbidden for staging, production, shared databases, or any database whose local ownership is uncertain.

Version History

  • c2ffb56 Current 2026-08-19 23:55

Same Skill Collection

.claude/skills/api-conventions/SKILL.md
.claude/skills/create-e2e-test/SKILL.md
.claude/skills/create-module/SKILL.md
.claude/skills/mx-pg-controller-migration/SKILL.md
.claude/skills/mx-review/SKILL.md
.claude/skills/mxs-cli-ai-author/SKILL.md
.claude/skills/release-core/SKILL.md
.claude/skills/run-test/SKILL.md
.claude/skills/zod-patterns/SKILL.md
.claude/skills/mx-migration-author/SKILL.md

Metadata

Files
0
Version
c2ffb56
Hash
cf7c6ec8
Indexed
2026-08-19 23:55

Главная - Вики-сайт
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-20 10:17
浙ICP备14020137号-1 $Гость$