|
|
|
|
|
//
|
|
|
|
|
|
// Copyright (C) 2024 veypi <i@veypi.com>
|
|
|
|
|
|
// 2025-03-04 16:08:06
|
|
|
|
|
|
// Distributed under terms of the MIT license.
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
package api
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
|
apiAuth "github.com/veypi/vbase/api/auth"
|
|
|
|
|
|
"github.com/veypi/vbase/api/oauth"
|
|
|
|
|
|
"github.com/veypi/vbase/api/role"
|
|
|
|
|
|
"github.com/veypi/vbase/api/settings"
|
|
|
|
|
|
"github.com/veypi/vbase/api/user"
|
|
|
|
|
|
"github.com/veypi/vbase/api/verification"
|
|
|
|
|
|
"github.com/veypi/vbase/auth"
|
|
|
|
|
|
"github.com/veypi/vigo"
|
|
|
|
|
|
"github.com/veypi/vigo/contrib/common"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
var Router = vigo.NewRouter()
|
|
|
|
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
|
|
// 注册全局中间件
|
refactor: Remove multi-tenant org system and simplify auth
- Delete org API endpoints (add_member, create, del, get, list, member, patch, tree)
- Delete models/org.go and remove Org/OrgMember models
- Delete org-related test files (org_crud, org_load_middleware, org_permission, multi_tenant)
- Delete org test scripts (03_org_permission.sh, 04_org_load_middleware.sh)
- Simplify auth/auth.go by removing org context and role loading logic
- Remove org claims from JWT tokens and login/register responses
- Redesign Permission model with hierarchical level-based access control
- Add auth/design.md with new permission system specification
- Update user and role APIs to work without org context
5 days ago
|
|
|
|
Router.Use(auth.VBaseAuth.Login())
|
|
|
|
|
|
Router.After(common.JsonResponse, common.JsonErrorResponse)
|
|
|
|
|
|
|
refactor: Remove multi-tenant org system and simplify auth
- Delete org API endpoints (add_member, create, del, get, list, member, patch, tree)
- Delete models/org.go and remove Org/OrgMember models
- Delete org-related test files (org_crud, org_load_middleware, org_permission, multi_tenant)
- Delete org test scripts (03_org_permission.sh, 04_org_load_middleware.sh)
- Simplify auth/auth.go by removing org context and role loading logic
- Remove org claims from JWT tokens and login/register responses
- Redesign Permission model with hierarchical level-based access control
- Add auth/design.md with new permission system specification
- Update user and role APIs to work without org context
5 days ago
|
|
|
|
// 初始化角色
|
|
|
|
|
|
auth.VBaseAuth.AddRole("admin", "管理员", "*:7")
|
|
|
|
|
|
auth.VBaseAuth.AddRole("user", "普通用户")
|
|
|
|
|
|
|
|
|
|
|
|
// 子路由挂载
|
|
|
|
|
|
Router.Extend("/auth", apiAuth.Router)
|
|
|
|
|
|
Router.Extend("/users", user.Router)
|
|
|
|
|
|
Router.Extend("/roles", role.Router)
|
|
|
|
|
|
Router.Extend("/oauth", oauth.Router)
|
|
|
|
|
|
Router.Extend("/settings", settings.Router)
|
|
|
|
|
|
Router.Extend("/verification", verification.Router)
|
|
|
|
|
|
|
|
|
|
|
|
// 404 处理
|
|
|
|
|
|
Router.Any("/**", vigo.SkipBefore, "拦截未注册的api请求,返回404", func(x *vigo.X) error {
|
|
|
|
|
|
return vigo.ErrNotFound
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|