Skip to main content

monolith-auth-and-sessions

Use when implementing login/signup/logout, access control, and cookie-backed session logic in this Monolith app.

跳到安装

来源信息

仓库
cggonzal/monolith
最近来源活动
2026年2月14日 03:11
检测到的 SKILL.md 语言
英语
星标
0
分支
0

安装方式

默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。

检查来源文件

决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。

正在显示 SKILL.md

SKILL.md
来源说明 · 只读预览
name
monolith-auth-and-sessions
description
Use when implementing login/signup/logout, access control, and cookie-backed session logic in this Monolith app.
# Monolith Auth and Sessions ## Use this skill when - Adding authentication or protecting routes. - Reading/writing session values. ## Core components - Session package: `app/session/session.go` - Auth middleware and controller (generated by auth scaffold) - Config secret: `config.SECRET_KEY` ## Bootstrap auth Run: `make generator authentication` Scaffold includes: - `User` model - session helpers - auth middleware - auth controller - login/signup templates - routes for `/login`, `/signup`, `/logout` ## Session model - Session store is Gorilla cookie store. - Initialized once in `session.InitSession()`. - Standard keys include login flag and email. ## Route protection pattern Wrap handlers with login/admin middleware decorators. If user is anonymous, redirect to `/login`. ## Security notes - Always set `SECRET_KEY` in production. - Never trust only client-side state for authorization decisions. - Re-check privileges server-side in middleware.
在 GitHub 查看