Files
yunzerwebsiteallinone/go/routers/auth/auth.go
T

82 lines
5.5 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Package auth 统一认证中心(UAC)路由:api.yunzer.cn/auth
//
// 重要:该路由组必须在 router.go 的所有运行模式下都注册
// (platform / backend / index / api / app / all),
// 否则对应模式下认证中心不可用。
package auth
import (
authctl "server/controllers/auth"
beego "github.com/beego/beego/v2/server/web"
)
// Register 注册认证中心路由
func Register() {
// ---- OIDC 标准端点 ----
beego.Router("/auth/.well-known/openid-configuration", &authctl.AuthOidcController{}, "get:Discovery")
beego.Router("/auth/jwks.json", &authctl.AuthOidcController{}, "get:JWKS")
beego.Router("/auth/authorize", &authctl.AuthOidcController{}, "get:Authorize")
beego.Router("/auth/token", &authctl.AuthOidcController{}, "post:Token")
beego.Router("/auth/userinfo", &authctl.AuthOidcController{}, "get:UserInfo;post:UserInfo")
beego.Router("/auth/introspect", &authctl.AuthOidcController{}, "post:Introspect")
beego.Router("/auth/revoke", &authctl.AuthOidcController{}, "post:Revoke")
// ---- 第三方登录(微信/钉钉/飞书/QQ/GitHub/Google) ----
beego.Router("/auth/third/list", &authctl.AuthThirdController{}, "get:List")
beego.Router("/auth/third/:provider/authorize", &authctl.AuthThirdController{}, "get:Authorize")
beego.Router("/auth/third/:provider/callback", &authctl.AuthThirdController{}, "get:Callback")
beego.Router("/auth/third/bind", &authctl.AuthThirdController{}, "post:Bind")
beego.Router("/auth/third/unbind", &authctl.AuthThirdController{}, "post:Unbind")
beego.Router("/auth/third/bound", &authctl.AuthThirdController{}, "get:BoundList")
// 自助页面(浏览器访问)
beego.Router("/auth/bind", &authctl.AuthThirdController{}, "get:BindPage")
beego.Router("/auth/devices", &authctl.AuthSessionController{}, "get:DevicesPage")
beego.Router("/auth/devices/kick", &authctl.AuthSessionController{}, "get:KickPage")
beego.Router("/auth/third/:provider/unbind", &authctl.AuthThirdController{}, "get:UnbindPage")
// ---- 登录与会话 ----
// 注意:beego 同一路径重复 Router 会覆盖,故 /auth/logout 只注册一次
beego.Router("/auth/login", &authctl.AuthLoginController{}, "get:LoginPage;post:LoginSubmit")
beego.Router("/auth/logout", &authctl.AuthLoginController{}, "get:LogoutPage;post:LogoutAction")
beego.Router("/auth/clear-site-data", &authctl.AuthLoginController{}, "post:ClearSiteData")
beego.Router("/auth/tenants", &authctl.AuthLoginController{}, "get:Tenants")
beego.Router("/auth/switch-tenant", &authctl.AuthLoginController{}, "post:SwitchTenant")
beego.Router("/auth/sessions", &authctl.AuthLoginController{}, "get:Sessions")
beego.Router("/auth/sessions/kick", &authctl.AuthLoginController{}, "post:KickSession")
beego.Router("/auth/verify-config", &authctl.AuthLoginController{}, "get:VerifyConfig")
// ---- 自助账户:两步式注册 / 找回密码 ----
// 第一步核验身份:手机号(短信验证码)或账号(服务号验证码);第二步企业归属
beego.Router("/auth/register", &authctl.AuthAccountController{}, "get:RegisterPage")
beego.Router("/auth/register/send-code", &authctl.AuthAccountController{}, "post:SendRegisterCode")
beego.Router("/auth/register/verify", &authctl.AuthAccountController{}, "post:RegisterVerify")
beego.Router("/auth/register/wechat/start", &authctl.AuthAccountController{}, "get:WechatStart")
beego.Router("/auth/register/wechat/status", &authctl.AuthAccountController{}, "get:WechatStatus")
// 账号注册的微信核验(小程序方案):小程序码扫码 → 小程序内确认 → 网页继续
beego.Router("/auth/register/mini/start", &authctl.AuthAccountController{}, "get:WechatMiniStart")
beego.Router("/auth/register/mini/status", &authctl.AuthAccountController{}, "get:WechatMiniStatus")
beego.Router("/auth/register/mini/confirm", &authctl.AuthWechatMiniController{}, "post:RegisterConfirm")
beego.Router("/auth/register/tenant/search", &authctl.AuthAccountController{}, "get:TenantSearch")
beego.Router("/auth/register/apply-join", &authctl.AuthAccountController{}, "post:ApplyJoin")
beego.Router("/auth/register/apply-create", &authctl.AuthAccountController{}, "post:ApplyCreate")
beego.Router("/auth/register/finish", &authctl.AuthAccountController{}, "post:FinishSkip")
beego.Router("/auth/register/upload-license", &authctl.AuthAccountController{}, "post:UploadLicense")
beego.Router("/auth/forgot", &authctl.AuthAccountController{}, "get:ForgotPage;post:ResetSubmit")
beego.Router("/auth/forgot/send-code", &authctl.AuthAccountController{}, "post:SendResetCode")
// 微信扫码登录(未认证公众号:服务号二维码 + 登录码 + 公众号内确认链接)
beego.Router("/auth/wechat/scan/start", &authctl.AuthLoginController{}, "post:WechatScanStart")
beego.Router("/auth/wechat/scan/status", &authctl.AuthLoginController{}, "get:WechatScanStatus")
// 微信小程序一键登录(wx.login code + getPhoneNumber 动态 code 换登录态)
beego.Router("/auth/wechat/miniapp/config", &authctl.AuthWechatMiniController{}, "get:Config")
beego.Router("/auth/wechat/miniapp/login", &authctl.AuthWechatMiniController{}, "post:Login")
// 已登录态下绑定 openid(认证中/无手机号能力时的兜底一键登录前置步骤)
beego.Router("/auth/wechat/miniapp/bind", &authctl.AuthWechatMiniController{}, "post:Bind")
// 移动端免登录票据:把移动端登录态桥接到 Web 端,避免 webview 内二次登录
beego.Router("/auth/app-ticket", &authctl.AuthAppTicketController{}, "post:Create")
beego.Router("/auth/app-ticket/exchange", &authctl.AuthAppTicketController{}, "post:Exchange")
}