feat: 客户端oauth2认证模块
This commit is contained in:
17
src/modules/auth/model/oauth2_body.go
Normal file
17
src/modules/auth/model/oauth2_body.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package model
|
||||
|
||||
// TokenBody 获取访问令牌参数
|
||||
type TokenBody struct {
|
||||
ClientId string `json:"clientId" binding:"required"` // 申请应用时获得的client_id
|
||||
ClientSecret string `json:"clientSecret" binding:"required"` // 申请应用时分配的secret
|
||||
GrantType string `json:"grantType" binding:"required,oneof=authorization_code refresh_token"` // 请求的类型,此处的值固定为 authorization_code/refresh_token
|
||||
Code string `json:"code"` // 授权拿到的code值
|
||||
RefreshToken string `json:"refreshToken"` // 刷新令牌
|
||||
}
|
||||
|
||||
// CodeQuery 重定向授权码参数
|
||||
type CodeQuery struct {
|
||||
RedirectUrl string `form:"redirectUrl" binding:"required"` // 授权回调地址
|
||||
ClientId string `form:"clientId" binding:"required"` // 申请得到的客户端ID
|
||||
State string `form:"state" binding:"required"` // 随机字符串,认证服务器会原封不动地返回这个值
|
||||
}
|
||||
22
src/modules/auth/model/oauth2_client.go
Normal file
22
src/modules/auth/model/oauth2_client.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package model
|
||||
|
||||
// Oauth2Client 用户授权第三方应用表 oauth2_client
|
||||
type Oauth2Client struct {
|
||||
Id int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"` // 应用ID
|
||||
ClientId string `gorm:"column:client_id" json:"clientId"` // 应用的唯一标识
|
||||
ClientSecret string `gorm:"column:client_secret" json:"clientSecret"` // 应用的凭证秘钥
|
||||
Title string `gorm:"column:title" json:"title"` // 应用名称
|
||||
IPWhite string `gorm:"column:ip_white" json:"ipWhite"` // IP白名单
|
||||
DelFlag string `gorm:"column:del_flag" json:"delFlag"` // 删除标记(0存在 1删除)
|
||||
LoginIp string `gorm:"column:login_ip" json:"loginIp"` // 最后登录IP
|
||||
LoginTime int64 `gorm:"column:login_time" json:"loginTime"` // 最后登录时间
|
||||
CreateBy string `gorm:"column:create_by" json:"createBy"` // 创建者
|
||||
CreateTime int64 `gorm:"column:create_time" json:"createTime"` // 创建时间
|
||||
UpdateBy string `gorm:"column:update_by" json:"updateBy"` // 更新者
|
||||
UpdateTime int64 `gorm:"column:update_time" json:"updateTime"` // 更新时间
|
||||
Remark string `gorm:"column:remark" json:"remark"` // 备注
|
||||
}
|
||||
|
||||
func (*Oauth2Client) TableName() string {
|
||||
return "oauth2_client"
|
||||
}
|
||||
19
src/modules/auth/model/oauth2_log_login.go
Normal file
19
src/modules/auth/model/oauth2_log_login.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package model
|
||||
|
||||
// Oauth2LogLogin 用户授权第三方应用登录日志表
|
||||
type Oauth2LogLogin struct {
|
||||
ID int64 `json:"id" gorm:"column:id;primaryKey;autoIncrement"` // 登录ID
|
||||
ClientId string `json:"clientId" gorm:"column:client_id"` // 应用的唯一标识
|
||||
LoginIp string `json:"loginIp" gorm:"column:login_ip"` // 登录IP地址
|
||||
LoginLocation string `json:"loginLocation" gorm:"column:login_location"` // 登录地点
|
||||
Browser string `json:"browser" gorm:"column:browser"` // 浏览器类型
|
||||
OS string `json:"os" gorm:"column:os"` // 操作系统
|
||||
StatusFlag string `json:"statusFlag" gorm:"column:status_flag"` // 登录状态(0失败 1成功)
|
||||
Msg string `json:"msg" gorm:"column:msg"` // 提示消息
|
||||
LoginTime int64 `json:"loginTime" gorm:"column:login_time"` // 登录时间
|
||||
}
|
||||
|
||||
// TableName 表名称
|
||||
func (*Oauth2LogLogin) TableName() string {
|
||||
return "oauth2_log_login"
|
||||
}
|
||||
Reference in New Issue
Block a user