forked from suyuan32/simple-admin-core
/
oauth_provider.go
63 lines (56 loc) · 1.83 KB
/
oauth_provider.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package schema
import (
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/field"
"github.com/huuhoait/simple-admin-common/orm/ent/mixins"
)
type OauthProvider struct {
ent.Schema
}
func (OauthProvider) Fields() []ent.Field {
return []ent.Field{
field.String("name").Unique().
Comment("The provider's name | 提供商名称").
Annotations(entsql.WithComments(true)),
field.String("client_id").
Comment("The client id | 客户端 id").
Annotations(entsql.WithComments(true)),
field.String("client_secret").
Comment("The client secret | 客户端密钥").
Annotations(entsql.WithComments(true)),
field.String("redirect_url").
Comment("The redirect url | 跳转地址").
Annotations(entsql.WithComments(true)),
field.String("scopes").
Comment("The scopes | 权限范围").
Annotations(entsql.WithComments(true)),
field.String("auth_url").
Comment("The auth url of the provider | 认证地址").
Annotations(entsql.WithComments(true)),
field.String("token_url").
Comment("The token url of the provider | 获取 token地址").
Annotations(entsql.WithComments(true)),
field.Uint64("auth_style").
Comment("The auth style, 0: auto detect 1: third party log in 2: log in with username and password | 鉴权方式" +
" 0 自动 1 第三方登录 2 使用用户名密码").
Annotations(entsql.WithComments(true)),
field.String("info_url").
Comment("The URL to request user information by token | 用户信息请求地址").
Annotations(entsql.WithComments(true)),
}
}
func (OauthProvider) Mixin() []ent.Mixin {
return []ent.Mixin{
mixins.IDMixin{},
}
}
func (OauthProvider) Edges() []ent.Edge {
return nil
}
func (OauthProvider) Annotations() []schema.Annotation {
return []schema.Annotation{
entsql.Annotation{Table: "sys_oauth_providers"},
}
}