spa-auth-development

单页应用(SPA)认证开发助手。用于开发基于 Cookie 的 Sanctum 认证流程、Vue Router 路由守卫、认证状态存储、登录/注册/密码重置页面及 CORS/会话配置,覆盖从 CSRF Cookie 到受保护 API 调用的完整认证生命周期。

仓库最近推送
GitHub Stars
147
Forks
61
Issues / PRs
5

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "spa-auth-development":https://skillpi.com/zh/skills/deepskill-1d942f979102a7535ea881a95c4d0c56b187095ae3dcb59be3f09bed0300cbb0。安装前核对上游来源和版本:https://github.com/gdarko/laravel-vue-starter。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

github.com

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

单页应用(SPA)认证开发助手。用于开发基于 Cookie 的 Sanctum 认证流程、Vue Router 路由守卫、认证状态存储、登录/注册/密码重置页面及 CORS/会话配置,覆盖从 CSRF Cookie 到受保护 API 调用的完整认证生命周期。

0 下载

介绍来源: third_party · gdarko · 0.0.1 参考来源

SkillPi 解读

能完成的任务
翻译待完成,请参阅来源文档。
实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: spa-auth-development
description: "Activate when working on SPA authentication flow, Sanctum cookie-based auth, Vue Router guards, auth store, login/register/password reset pages, or CORS/session configuration. Covers the full auth lifecycle from CSRF cookie to protected API calls."
license: MIT
metadata:
  author: project

SPA Authentication Development

This project uses a decoupled SPA architecture where Vue handles all routing and Laravel serves as a JSON API with Sanctum cookie-based authentication.

Auth Flow

  1. Vue app calls GET /sanctum/csrf-cookie to get XSRF token
  2. User submits login form → POST /login (Fortify handles this)
  3. Laravel returns session cookie + user data
  4. All subsequent API calls include the session cookie automatically (withCredentials: true)
  5. Protected routes use auth:sanctum middleware

Key Files

Backend

  • config/sanctum.php — Stateful domains, guards, CSRF middleware
  • config/cors.php — CORS paths (api/*, login, logout, register, etc.) with supports_credentials: true
  • config/fortify.php — Auth features (registration, password reset, email verification)
  • app/Providers/FortifyServiceProvider.php — Binds Fortify actions and custom LoginResponse
  • app/Http/Responses/LoginResponse.php — Returns JSON with user data for SPA
  • app/Http/Middleware/ApplyLocale.php — Sets locale from X-Locale header
  • bootstrap/app.php — statefulApi() middleware, apply_locale alias

Frontend

  • stores/auth.js — Pinia store with login, register, logout, getCurrentUser
  • services/AuthService.ts — API calls for auth endpoints (login, register, forgot/reset password, etc.)
  • router/index.js — Navigation guards checking requiresAuth and requiresAbility route meta
  • plugins/axios.js — Axios configured with withCredentials, X-Locale header, base URL from window.AppConfig

CORS Configuration

For the SPA to work, these .env values must match:

APP_URL=http://localhost:8000
SANCTUM_STATEFUL_DOMAINS=localhost:8000
SESSION_DOMAIN=localhost

Route Guards

Routes use meta fields for auth:

  • requiresAuth: true — Redirects to login if not authenticated
  • requiresAbility: 'ability_name' — Checks user abilities via Bouncer
  • isPublicAuthPage: true — Redirects to dashboard if already authenticated
  • isOwner: true — Owner-only routes

Authorization

Uses Silber Bouncer with abilities:

  • Abilities defined in resources/app/stub/abilities.js (CREATE_USER, EDIT_USER, etc.)
  • Checked in Vue Router guards and sidebar menu visibility
  • Backend uses Gate::authorize() in controllers
  • Roles seeded in database/seeders/BouncerSeeder.php

当前收录版本

0.0.1

核对来源版本 ↗

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值85/100

亮点

  • 提供完整的 SPA 认证开发指南,涵盖 Laravel Sanctum、Vue Router 守卫、CORS 配置等核心内容
  • 解决开发者在构建现代 SPA 应用时的实际痛点,实用性强
触发精准95/100

亮点

  • 触发词精准完整,覆盖 SPA 认证流程、Sanctum、Vue Router 守卫等多种场景
  • 边界清晰,用户能准确判断是否适用
结构规范95/100

亮点

  • 文档结构清晰,分章节详细描述 Auth Flow、Key Files、CORS Configuration 等
  • 包含端到端示例和完整 frontmatter,易于理解和执行
执行可靠90/100

亮点

  • 工具来源明确,参数配置正确,覆盖主要异常处理
  • 提供了完整的认证生命周期指导,从 CSRF Cookie 到受保护 API 调用
证据可验 (前四项均值)91/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。

文档引用的域名或地址

这些地址可能用于文档链接或示例,不是已批准的联网清单。使用前核对实际目的地及发送的数据。

  • localhost

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。