Documentation
¶
Index ¶
- func ProvideRedisClient() *redis.Client
- type Logger
- type Login
- func (a *Login) GetCaptcha(ctx context.Context) (*schema.Captcha, error)
- func (a *Login) GetUserInfo(ctx context.Context) (*schema.User, error)
- func (a *Login) Login(ctx context.Context, formItem *schema.LoginForm) (*schema.LoginToken, error)
- func (a *Login) Logout(ctx context.Context) error
- func (a *Login) LogoutWithRefreshToken(ctx context.Context, accessToken string, refreshToken string) error
- func (a *Login) ParseUserID(c *gin.Context) (string, error)
- func (a *Login) QueryMenus(ctx context.Context) (schema.Menus, error)
- func (a *Login) RefreshToken(ctx context.Context) (*schema.LoginToken, error)
- func (a *Login) RefreshTokenWithRefreshToken(ctx context.Context, refreshToken string) (*schema.LoginToken, error)
- func (a *Login) ResponseCaptcha(ctx context.Context, w http.ResponseWriter, id string, reload bool) error
- func (a *Login) UpdatePassword(ctx context.Context, updateItem *schema.UpdateLoginPassword) error
- func (a *Login) UpdateUser(ctx context.Context, updateItem *schema.UpdateCurrentUser) error
- type Menu
- func (a *Menu) Create(ctx context.Context, formItem *schema.MenuForm) (*schema.Menu, error)
- func (a *Menu) Delete(ctx context.Context, id string) error
- func (a *Menu) Get(ctx context.Context, id string) (*schema.Menu, error)
- func (a *Menu) InitFromFile(ctx context.Context, menuFile string) error
- func (a *Menu) Query(ctx context.Context, params schema.MenuQueryParam) (*schema.MenuQueryResult, error)
- func (a *Menu) Update(ctx context.Context, id string, formItem *schema.MenuForm) error
- type OAuth
- func (a *OAuth) BuildLoginURL(ctx context.Context, provider, redirect string) (string, error)
- func (a *OAuth) ExchangeTicket(ctx context.Context, ticket string) (*schema.LoginToken, error)
- func (a *OAuth) GetEnabledProviders(ctx context.Context) []schema.OAuthProvider
- func (a *OAuth) HandleCallback(ctx context.Context, provider, code, state string) (string, error)
- func (a *OAuth) ResolveProfile(ctx context.Context, profile schema.OAuthProfile) (*schema.OAuthResolveResult, error)
- type Role
- func (a *Role) Create(ctx context.Context, formItem *schema.RoleForm) (*schema.Role, error)
- func (a *Role) Delete(ctx context.Context, id string) error
- func (a *Role) Get(ctx context.Context, id string) (*schema.Role, error)
- func (a *Role) Query(ctx context.Context, params schema.RoleQueryParam) (*schema.RoleQueryResult, error)
- func (a *Role) Update(ctx context.Context, id string, formItem *schema.RoleForm) error
- type Tenant
- func (a *Tenant) Create(ctx context.Context, formItem *schema.TenantForm) (*schema.Tenant, error)
- func (a *Tenant) Delete(ctx context.Context, id string) error
- func (a *Tenant) Get(ctx context.Context, id string) (*schema.Tenant, error)
- func (a *Tenant) Query(ctx context.Context, params schema.TenantQueryParam) (*schema.TenantQueryResult, error)
- func (a *Tenant) Update(ctx context.Context, id string, formItem *schema.TenantForm) error
- type TenantEndpoint
- type TenantModel
- func (a *TenantModel) ExecTrans(ctx context.Context, fn func(context.Context) error) error
- func (a *TenantModel) GetAuthorizedModelIDs(ctx context.Context, tenantCode string) ([]string, error)
- func (a *TenantModel) SaveBindings(ctx context.Context, tenantCode string, modelIDs []string, creator string) error
- type User
- func (a *User) Create(ctx context.Context, formItem *schema.UserForm) (*schema.User, error)
- func (a *User) Delete(ctx context.Context, id string) error
- func (a *User) Get(ctx context.Context, id string) (*schema.User, error)
- func (a *User) GetRoleIDs(ctx context.Context, id string) ([]string, error)
- func (a *User) Query(ctx context.Context, params schema.UserQueryParam) (*schema.UserQueryResult, error)
- func (a *User) ResetPassword(ctx context.Context, id string) error
- func (a *User) Update(ctx context.Context, id string, formItem *schema.UserForm) error
- type UserAPIKey
- func (a *UserAPIKey) Create(ctx context.Context, formItem *schema.UserAPIKeyForm) (*schema.UserAPIKey, error)
- func (a *UserAPIKey) Delete(ctx context.Context, id string) error
- func (a *UserAPIKey) Get(ctx context.Context, id string) (*schema.UserAPIKey, error)
- func (a *UserAPIKey) GetPlaintext(ctx context.Context, id string) (string, error)
- func (a *UserAPIKey) Query(ctx context.Context, params schema.UserAPIKeyQueryParam) (*schema.UserAPIKeyQueryResult, error)
- func (a *UserAPIKey) Update(ctx context.Context, id string, formItem *schema.UserAPIKeyForm) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ProvideRedisClient ¶
ProvideRedisClient 提供 Redis 客户端单例以供同步使用
Types ¶
type Logger ¶
Logger management
func (*Logger) Query ¶
func (a *Logger) Query(ctx context.Context, params schema.LoggerQueryParam) (*schema.LoggerQueryResult, error)
Query loggers from the data access object based on the provided parameters and options.
type Login ¶
type Login struct {
Cache cachex.Cacher
Auth jwtx.Auther
UserDAL *dal.User
UserRoleDAL *dal.UserRole
MenuDAL *dal.Menu
UserBIZ *User
AuditLogBIZ *opsBiz.AuditLog
}
Login management for RBAC
func (*Login) GetCaptcha ¶
This function generates a new captcha ID and returns it as a `schema.Captcha` struct. The length of the captcha is determined by the `config.C.Util.Captcha.Length` configuration value.
func (*Login) GetUserInfo ¶
Get user info
func (*Login) LogoutWithRefreshToken ¶
func (a *Login) LogoutWithRefreshToken(ctx context.Context, accessToken string, refreshToken string) error
LogoutWithRefreshToken logs out and revokes both access token and refresh token
func (*Login) QueryMenus ¶
Query menus based on user permissions
func (*Login) RefreshToken ¶
func (*Login) RefreshTokenWithRefreshToken ¶
func (a *Login) RefreshTokenWithRefreshToken(ctx context.Context, refreshToken string) (*schema.LoginToken, error)
RefreshTokenWithRefreshToken uses a refresh token to get new access token (and new refresh token)
func (*Login) ResponseCaptcha ¶
func (a *Login) ResponseCaptcha(ctx context.Context, w http.ResponseWriter, id string, reload bool) error
Response captcha image
func (*Login) UpdatePassword ¶
Change login password
func (*Login) UpdateUser ¶
Update current user info
type Menu ¶
type Menu struct {
Cache cachex.Cacher
Trans *util.Trans
MenuDAL *dal.Menu
MenuResourceDAL *dal.MenuResource
RoleMenuDAL *dal.RoleMenu
}
Menu management for RBAC
func (*Menu) Query ¶
func (a *Menu) Query(ctx context.Context, params schema.MenuQueryParam) (*schema.MenuQueryResult, error)
Query menus from the data access object based on the provided parameters and options.
type OAuth ¶
type OAuth struct {
Cache cachex.Cacher
Trans *util.Trans
ExternalIdentityDAL *dal.ExternalIdentity
UserDAL *dal.User
UserRoleDAL *dal.UserRole
TenantDAL *dal.Tenant
TenantModelDAL *dal.TenantModel
RoleDAL *dal.Role
LoginBIZ *Login
HTTPClient *http.Client
}
func (*OAuth) BuildLoginURL ¶
func (*OAuth) ExchangeTicket ¶
func (*OAuth) GetEnabledProviders ¶
func (a *OAuth) GetEnabledProviders(ctx context.Context) []schema.OAuthProvider
func (*OAuth) HandleCallback ¶
func (*OAuth) ResolveProfile ¶
func (a *OAuth) ResolveProfile(ctx context.Context, profile schema.OAuthProfile) (*schema.OAuthResolveResult, error)
type Role ¶
type Role struct {
Cache cachex.Cacher
Trans *util.Trans
RoleDAL *dal.Role
RoleMenuDAL *dal.RoleMenu
UserRoleDAL *dal.UserRole
AuditLogBIZ *opsBiz.AuditLog
}
Role management for RBAC
func (*Role) Query ¶
func (a *Role) Query(ctx context.Context, params schema.RoleQueryParam) (*schema.RoleQueryResult, error)
Query roles from the data access object based on the provided parameters and options.
type Tenant ¶
type Tenant struct {
Trans *util.Trans
TenantDAL *dal.Tenant
UserDAL *dal.User
RedisClient *redis.Client
AuditLogBIZ *opsBiz.AuditLog
}
Tenant management for RBAC
func (*Tenant) Query ¶
func (a *Tenant) Query(ctx context.Context, params schema.TenantQueryParam) (*schema.TenantQueryResult, error)
Query tenants from the data access object based on the provided parameters and options.
type TenantEndpoint ¶
type TenantEndpoint struct {
Trans *util.Trans
TenantEndpointDAL *dal.TenantEndpoint
RedisClient *redis.Client
AuditLogBIZ *opsBiz.AuditLog
}
TenantEndpoint 租户端点绑定业务逻辑类
func (*TenantEndpoint) GetAllowedEndpointIDs ¶
func (a *TenantEndpoint) GetAllowedEndpointIDs(ctx context.Context, tenantCode, modelID string) ([]string, error)
GetAllowedEndpointIDs 查询租户指定模型下已经允许的端点 ID 列表
func (*TenantEndpoint) SaveEndpoints ¶
func (a *TenantEndpoint) SaveEndpoints(ctx context.Context, tenantCode, modelID string, endpointIDs []string, creator string) error
SaveEndpoints 在事务中保存允许的端点白名单,并在成功后同步至 Redis
type TenantModel ¶
type TenantModel struct {
Trans *util.Trans
TenantModelDAL *dal.TenantModel
RedisClient *redis.Client
AuditLogBIZ *opsBiz.AuditLog
}
TenantModel management for RBAC
func (*TenantModel) GetAuthorizedModelIDs ¶
func (a *TenantModel) GetAuthorizedModelIDs(ctx context.Context, tenantCode string) ([]string, error)
GetAuthorizedModelIDs returns all model IDs authorized for the tenant.
func (*TenantModel) SaveBindings ¶
func (a *TenantModel) SaveBindings(ctx context.Context, tenantCode string, modelIDs []string, creator string) error
SaveBindings deletes old bindings of the tenant and inserts new ones inside a transaction.
type User ¶
type User struct {
Cache cachex.Cacher
Trans *util.Trans
UserDAL *dal.User
UserRoleDAL *dal.UserRole
AuditLogBIZ *opsBiz.AuditLog
}
User management for RBAC
func (*User) GetRoleIDs ¶
func (*User) Query ¶
func (a *User) Query(ctx context.Context, params schema.UserQueryParam) (*schema.UserQueryResult, error)
Query users from the data access object based on the provided parameters and options.
type UserAPIKey ¶
type UserAPIKey struct {
Trans *util.Trans
UserAPIKeyDAL *dal.UserAPIKey
UserDAL *dal.User
RedisClient *redis.Client
AuditLogBIZ *opsBiz.AuditLog
}
UserAPIKey 业务逻辑处理结构体
func (*UserAPIKey) Create ¶
func (a *UserAPIKey) Create(ctx context.Context, formItem *schema.UserAPIKeyForm) (*schema.UserAPIKey, error)
Create 创建用户 API Key(仅在此接口返回新生成的明文 API Key 供前台复制)
func (*UserAPIKey) Delete ¶
func (a *UserAPIKey) Delete(ctx context.Context, id string) error
Delete 逻辑删除用户 API Key
func (*UserAPIKey) Get ¶
func (a *UserAPIKey) Get(ctx context.Context, id string) (*schema.UserAPIKey, error)
Get 获取单条 API Key 记录(已掩码脱敏)
func (*UserAPIKey) GetPlaintext ¶
GetPlaintext 获取单条 API Key 的明文(用于复制操作) 安全考虑:仅允许管理员或密钥所属用户获取明文
func (*UserAPIKey) Query ¶
func (a *UserAPIKey) Query(ctx context.Context, params schema.UserAPIKeyQueryParam) (*schema.UserAPIKeyQueryResult, error)
Query 分页查询用户 API Key 列表(已掩码脱敏)
func (*UserAPIKey) Update ¶
func (a *UserAPIKey) Update(ctx context.Context, id string, formItem *schema.UserAPIKeyForm) error
Update 更新用户 API Key(支持更新 Name, Status, Credits, ExpiresAt, Description)