/
model.go
81 lines (71 loc) · 3.07 KB
/
model.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package db
import (
"github.com/go-webauthn/webauthn/protocol"
"github.com/google/uuid"
)
type User struct {
Email string `gorm:"primary_key;unique;not null"`
PasswordHash []byte `gorm:"not null"`
DisplayName string `gorm:""`
WebAuthnUserID uuid.UUID `gorm:"type:uuid;default:uuid_generate_v4()"`
Credentials []UserCredential
Roles []Role `gorm:"many2many:user_roles;"`
IsEnabled bool `gorm:"default:false;not null"`
}
type Client struct {
ClientID string `gorm:"primary_key;unique;not null"`
ClientSecret string `gorm:"not null"`
RedirectURI string
IsPublic bool
UserEmail string `gorm:"not null"`
User User `gorm:"foreignKey:UserEmail"`
}
type UserCredential struct {
ID []byte `gorm:"primary_key;unique;not null"`
PublicKey []byte `gorm:"unique;not null"`
AttestationType string `gorm:"not null"`
Transport []protocol.AuthenticatorTransport `gorm:"type:text[]"`
UserPresent bool `gorm:"not null"`
UserVerified bool `gorm:"not null"`
BackupEligible bool `gorm:"not null"`
BackupState bool `gorm:"not null"`
AAGUID []byte `gorm:"not null"`
SignCount uint32 `gorm:"not null"`
CloneWarning bool `gorm:"not null"`
Attachment protocol.AuthenticatorAttachment `gorm:"not null"`
UserEmail string `gorm:"uniqueIndex:idx_uniq_credential_name,priority:1;not null"`
FriendlyName string `gorm:"uniqueIndex:idx_uniq_credential_name,priority:2;not null"`
User User `gorm:"foreignKey:UserEmail"`
}
type Role struct {
Name string `gorm:"primary_key;unique;not null"`
}
type UserRole struct {
UserEmail string `gorm:"uniqueIndex:idx_uniq_user_role,priority:1;not null"`
RoleName string `gorm:"uniqueIndex:idx_uniq_user_role,priority:2;not null"`
User User `gorm:"foreignKey:UserEmail"`
Role Role `gorm:"foreignKey:RoleName"`
}
type UserConfirmation struct {
UserEmail string `gorm:"primary_key;unique;not null"`
OneTimePassword string `gorm:"not null"`
ExpiryTime int64 `gorm:"not null"`
ConfirmedTime int64 `gorm:"not null"`
User User `gorm:"foreignKey:UserEmail"`
}
type Scope struct {
Name string `gorm:"primary_key;unique;not null"`
}
type ClientScope struct {
ClientID string `gorm:"uniqueIndex:idx_uniq_client_scope,priority:1;not null"`
ScopeName string `gorm:"uniqueIndex:idx_uniq_client_scope,priority:2;not null"`
Client Client `gorm:"foreignKey:ClientID"`
Scope Scope `gorm:"foreignKey:ScopeName"`
}
type OidcClient struct {
Name string `gorm:"primary_key;unique;not null"`
ClientID string `gorm:"not null"`
ClientSecret string `gorm:"not null"`
RedirectURI string `gorm:"not null"`
ButtonName string `gorm:"not null"`
}