ci: 添加 Docker 构建和推送工作流
- 新增 Dockerfile 和 .dockerignore 文件 - 添加 Gitea 持续集成工作流,用于构建和推送 Docker 镜像 - 新增 .gitignore 文件,忽略构建和配置文件 - 添加项目结构和规范文档,包括 TypeScript、模块化、API、数据库等规范 - 新增前端和后端的基础代码结构
This commit is contained in:
37
docs/sso-verify.md
Normal file
37
docs/sso-verify.md
Normal file
@@ -0,0 +1,37 @@
|
||||
```typescript
|
||||
// 为Gogs SSO单点登录提供的验证API
|
||||
authRoutes.get('/sso-verify', async (c) => {
|
||||
try {
|
||||
const auth = await initAuth()
|
||||
|
||||
// 从Authorization头获取令牌
|
||||
const token = c.req.header('Authorization')?.replace('Bearer ', '')
|
||||
|
||||
if (!token) {
|
||||
return c.text('Unauthorized', 401)
|
||||
}
|
||||
|
||||
// 验证令牌
|
||||
try {
|
||||
const userData = await auth.verifyToken(token)
|
||||
if (!userData) {
|
||||
return c.text('Invalid token', 401)
|
||||
}
|
||||
|
||||
// 导入GitUtils工具类并使用其formatUsername方法格式化用户名
|
||||
const username = GitUtils.formatUsername(userData.username, userData.id);
|
||||
|
||||
// 验证成功,设置用户名到响应头
|
||||
c.header('X-Username', username)
|
||||
|
||||
return c.text('OK', 200)
|
||||
} catch (tokenError) {
|
||||
log.auth('Token验证失败:', tokenError)
|
||||
return c.text('Invalid token', 401)
|
||||
}
|
||||
} catch (error) {
|
||||
log.auth('SSO验证失败:', error)
|
||||
return c.text('Authentication failed', 500)
|
||||
}
|
||||
})
|
||||
```
|
||||
Reference in New Issue
Block a user