Fastapi Auth Module Skill logo

Fastapi Auth Module Skill

Community
jiushiwon
fastapi-auth-module-skill

FastAPI 授权与企业组织架构模块一键叠加技能。面向已使用 fastapi-init-skill 生成的项目,标准化落地 RBAC、角色-菜单、部门/岗位/租户、数据权限、个人鉴权。触发词:"FastAPI 授权模块","Python 权限模块","FastAPI RBAC","角色菜单权限","企业组织架构","fastapi-auth-module","添加权限模块","帮我加一个 Python 鉴权模块"。

Overview

Publisherjiushiwon
Repositorywg-skills
Skill namefastapi-auth-module-skill
Stars
123
Forks
38
Bundled files
16
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 16 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by jiushiwon on GitHub. Read the source before you install it.

Installation

Install the Fastapi Auth Module Skill AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/jiushiwon/wg-skills/tree/main/vibeCoding/backend/python/fastapi-module/fastapi-auth-module-skill
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/jiushiwon/wg-skills.git /tmp/wg-skills
mkdir -p .claude/skills
cp -r /tmp/wg-skills/vibeCoding/backend/python/fastapi-module/fastapi-auth-module-skill .claude/skills/fastapi-auth-module-skill
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Fastapi Auth Module Skill in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Fastapi Auth Module Skill on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Fastapi Auth Module Skill is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

FastAPI Auth Module Skill

为 FastAPI 项目叠加一套企业级授权与组织架构能力,不是重新生成新项目。

定位

  • 目标:在已有 fastapi-init-skill 骨架上,添加可运行的 RBAC + 组织架构模块。
  • 不替代:不重复生成 fastapi-init-skill 已经提供的 JWT、统一响应、SQLModel 等基础设施。
  • 输出:模型、仓储、服务、路由、数据库迁移、接口契约、接入指南。

骨架依赖(子模块)

本模块是 fastapi-init-skill 的子模块,必须在骨架基础上使用。

使用前必须满足以下条件:

  1. ✅ 已安装 fastapi-init-skill(项目骨架)
  2. ✅ 骨架包含:JWT、统一响应、SQLModel、分页、目录结构
  3. ✅ 遵循骨架的表前缀、字段命名、软删除规范

检测逻辑:

  1. 读取用户项目根目录 SKILL.md 或 README.md
  2. 检测是否包含 fastapi-init-skill 相关内容
  3. 如未检测到骨架,提示:"本模块需要先安装 fastapi-init-skill 骨架"
  4. 如用户拒绝安装骨架,则终止并提示无法使用

用户问题(最多 3 个)

1. 现有项目的包名是什么?(默认从 fastapi-init-skill 推断,如 app)
2. 表前缀是什么?(默认 wg)
3. 是否需要数据权限(全部 / 本部门 / 本部门及以下 / 仅本人)?(默认需要)

核心能力清单

#能力说明
1租户(Tenant)多租户数据隔离,支持独立组织架构
2组织架构(Org)树形部门,支持 parent_id 递归
3岗位(Post)用户可绑定一个或多个岗位
4用户(SysUser)扩展基础 User,关联租户、部门、岗位、角色
5角色(Role)RBAC 核心,支持数据权限范围
6菜单/权限(Menu)树形菜单 + 权限标识(permission),用于前端路由与按钮级鉴权
7角色-菜单绑定多对多,控制角色可见菜单与接口权限
8用户-角色绑定多对多,一个用户可拥有多个角色
9数据权限按角色数据范围过滤:全部、本部门、本部门及以下、仅本人
10个人鉴权登录 / 登出 / 修改密码 / 当前用户详情 / 获取菜单树
11接口契约生成 api-contract-auth.md,与前端对齐

生成的模块结构

src/
├── auth/
│   ├── __init__.py
│   ├── constants.py              # 权限常量
│   ├── enums.py                 # 数据权限枚举
│   ├── dependencies.py          # 权限校验依赖
│   ├── schemas.py               # Pydantic schemas
│   ├── models.py                # SQLModel 模型
│   ├── routers/
│   │   ├── __init__.py
│   │   ├── auth.py              # 登录 / 登出 / 当前用户 / 菜单树
│   │   ├── users.py             # 用户 CRUD + 绑定角色/岗位
│   │   ├── roles.py             # 角色 CRUD + 绑定菜单
│   │   ├── menus.py             # 菜单树 CRUD
│   │   ├── orgs.py              # 组织架构树 CRUD
│   │   ├── posts.py             # 岗位 CRUD
│   │   └── tenants.py           # 租户 CRUD
│   └── services/
│       ├── __init__.py
│       ├── auth_service.py       # 认证服务
│       ├── user_service.py       # 用户服务
│       ├── role_service.py       # 角色服务
│       ├── menu_service.py       # 菜单服务
│       ├── org_service.py       # 组织架构服务
│       ├── post_service.py      # 岗位服务
│       ├── tenant_service.py    # 租户服务
│       └── data_scope.py        # 数据权限过滤

alembic/versions/auth_module.py   # 迁移文件

api-contract-auth.md              # 接口契约
docs/auth-module-guide.md         # 接入与扩展指南

v1.2.0+ 完整可运行:所有路由和服务层代码已补充完整,复制到项目后直接可用。

数据权限规则

数据范围含义使用场景
ALL全部数据超级管理员
DEPT_ONLY本部门数据部门经理
DEPT_AND_BELOW本部门及以下子部门区域负责人
SELF_ONLY仅本人数据普通员工

生成流程

  1. 确认已存在 FastAPI 骨架(含 JWT、统一响应、分页)。
  2. 询问用户包名、表前缀(默认 wg)、是否需要数据权限。
  3. 按 references/skeleton.py 生成 auth/ 下全部源码:
    • 将所有 {prefix} 占位符替换为用户指定的表前缀(如 wg_)
    • 将 src.auth 替换为用户的包名(如 app.auth)
  4. 生成 api-contract-auth.md 与 docs/auth-module-guide.md。
  5. 提示用户:
    • 用 alembic upgrade head 初始化表结构;
    • 若原项目已有 User 模型,建议用 SysUser 替换或扩展;
    • 重启服务后访问 /api/auth/menus 获取当前用户菜单树。

接口契约要点

  • 响应信封:{ code, message, data },与 frontend-request-skill 对齐。
  • 登录:POST /api/auth/login 返回 { accessToken, refreshToken, tokenType, expiresIn }。
  • 字段命名一律 camelCase(与 springboot-auth-module-skill 逐字对齐,前端一套可同时对接两端)。
  • 错误码一律负数业务码(-1001 参数错 / -1002 未登录 / -1003 无权限 / -1004 资源不存在 / -1005 数据权限越界 / -2000 系统异常,HTTP 始终 200)。
  • Python 实现:所有 Pydantic 模型必须 model_config = ConfigDict(populate_by_name=True, alias_generator=to_camel),兼容入参 snake_case / 出参 camelCase。
  • 当前用户:GET /api/auth/me 返回用户 + 角色 + 部门 + 岗位。
  • 菜单树:GET /api/auth/menus 返回当前用户可见的树形菜单。
  • 用户、角色、菜单、部门、岗位:标准分页 CRUD。

强制交付物

文档位置说明
接口契约api-contract-auth.md含登录、当前用户、菜单树、CRUD 全量接口 ✅ 已交付
接入指南docs/auth-module-guide.md表结构、数据权限、与 fastapi-init-skill 集成步骤

红线

  1. 不重复生成 FastAPI 基础骨架。
  2. 表名统一 {prefix}_sys_user、{prefix}_sys_role 等,遵循 database-design-skill 规范。
  3. 所有删除为软删除(deleted_at)。
  4. 菜单树使用 parent_id + sort_order,禁止嵌套集合。
  5. 接口鉴权先走 FastAPI 依赖注入 JWT 校验,再走角色-菜单权限校验。
  6. 所有注释、文档用中文。

与 java-auth-module-skill 对齐

  • 接口路径、字段命名、响应结构与 Java 版本完全一致
  • 确保前端一套 API 可同时对接 Java 和 Python 后端

后续迭代

  • 支持岗位数据权限、自定义数据权限规则。
  • 支持 OAuth2 / SSO 接入。
  • 与 java-auth-module-skill 保持 API 字段完全一致,方便前后端跨语言复用。

【考拉搞AI】,带你全面进入 VibeCoding 的世界~

触发关键词

FastAPI 授权模块、Python 权限模块、FastAPI RBAC、角色菜单权限、
企业组织架构、fastapi-auth-module、添加权限模块、帮我加一个 Python 鉴权模块

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Fastapi Auth Module Skill AI skill do?

FastAPI 授权与企业组织架构模块一键叠加技能。面向已使用 fastapi-init-skill 生成的项目,标准化落地 RBAC、角色-菜单、部门/岗位/租户、数据权限、个人鉴权。触发词:"FastAPI 授权模块","Python 权限模块","FastAPI RBAC","角色菜单权限","企业组织架构","fastapi-auth-module","添加权限模块","帮我加一个 Python 鉴权模块"。

Why use Fastapi Auth Module Skill on TypingMind?

Because you install it once and use it with any model. Fastapi Auth Module Skill is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Fastapi Auth Module Skill in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/jiushiwon/wg-skills/tree/main/vibeCoding/backend/python/fastapi-module/fastapi-auth-module-skill. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Fastapi Auth Module Skill?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Fastapi Auth Module Skill?

As many as you like. As long as a model supports skills, you can use Fastapi Auth Module Skill with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Fastapi Auth Module Skill AI skill free?

Yes. It is published on GitHub by jiushiwon under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇