models

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2024 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const (
	CONST_USERNAMEKEY = "user"
	CONST_USERIDKEY   = "userid"
	CONST_OUKEY       = "org"
	CONST_OUIDKEY     = "orgid"
)

Variables

This section is empty.

Functions

func Sync2Db

func Sync2Db(x *gorm.DB)

Sync2Db 将struct同步数据结构到数据库

Types

type Authorization_fake added in v0.0.2

type Authorization_fake struct {
	Id                    string `json:"id" gorm:"primary_key;type:varchar(36);not null"`
	Issuer                string `json:"iss" gorm:"type:varchar(256);"`
	ClientId              string `json:"client_id" gorm:"type:varchar(256);"`
	PrincipalName         string `json:"principal_name" gorm:"type:varchar(256);"`
	Subject               string `json:"subject" gorm:"type:varchar(256);"`
	GrantType             string `json:"grant_type" gorm:"type:varchar(256);"`
	ResponseType          string `json:"response_type" gorm:"type:varchar(256);"`
	Scope                 string `json:"scope" gorm:"type:varchar(256);"`
	Code                  string `json:"code" gorm:"type:varchar(256);index"`
	Nonce                 string `json:"nonce" gorm:"type:varchar(256);"`
	AccessToken           string `json:"access_token" gorm:"type:varchar(2560);index" `
	RefreshToken          string `json:"refresh_token" gorm:"type:varchar(256);index"`
	IDToken               string `json:"id_token" gorm:"type:varchar(2560);index"`
	CodeChallenge         string `json:"code_challenge" gorm:"type:varchar(256);"`
	CodeChallengeMethod   string `json:"code_challenge_method" gorm:"type:varchar(256);"`
	DeviceCode            string `json:"device_code" gorm:"type:varchar(256);index"`
	ExpiresAt             int64  `json:"expires_at"` //Unix timestamp
	RefreshTokenExpiresAt int64  `json:"refresh_token_expires_at"`
	UserCode              string `json:"user_code" gorm:"type:varchar(256);index"`
}

Ony use for define gorm db schema

func (*Authorization_fake) TableName added in v0.0.2

func (r *Authorization_fake) TableName() string

type Client

type Client struct {
	Enabled                           bool                           `gorm:"not null"`
	ClientId                          string                         `gorm:"uniqueIndex;type:varchar(256);not null"`
	GrantTypes                        string                         `gorm:"type:varchar(256)"`
	Scopes                            string                         `gorm:"type:varchar(256)"`
	RedirectUris                      string                         `gorm:"type:varchar(4096)"`
	ProtocolType                      string                         `gorm:"type:varchar(200);"`
	RequireSecret                     bool                           `gorm:"not null"`
	ClientName                        string                         `gorm:"type:varchar(200)"`
	Description                       string                         `gorm:"type:varchar(1000)"`
	ClientURI                         string                         `gorm:"type:varchar(2000)"`
	LogoURI                           string                         `gorm:"type:varchar(2000)"`
	RequireConsent                    bool                           `gorm:"not null"`
	AllowRememberConsent              bool                           `gorm:"not null"`
	AlwaysIncludeUserClaimsInIdToken  bool                           `gorm:"not null"`
	RequirePkce                       bool                           `gorm:"not null"`
	AllowPlainTextPkce                bool                           `gorm:"not null"`
	AllowAccessTokensViaBrowser       bool                           `gorm:"not null"`
	FrontChannelLogoutURI             string                         `gorm:"type:varchar(2000)"`
	FrontChannelLogoutSessionRequired bool                           `gorm:"not null"`
	BackChannelLogoutURI              string                         `gorm:"type:varchar(2000)"`
	BackChannelLogoutSessionRequired  bool                           `gorm:"not null"`
	AllowOfflineAccess                bool                           `gorm:"not null"`
	IdentityTokenLifetime             int                            `gorm:"type:int;not null"`
	AccessTokenLifetime               int                            `gorm:"type:int;not null"`
	AuthorizationCodeLifetime         int                            `gorm:"type:int;not null"`
	ConsentLifetime                   int                            `gorm:"type:int"`
	AbsoluteRefreshTokenLifetime      int                            `gorm:"type:int;not null"`
	SlidingRefreshTokenLifetime       int                            `gorm:"type:int;not null"`
	RefreshTokenUsage                 int                            `gorm:"type:int;not null"`
	UpdateAccessTokenClaimsOnRefresh  bool                           `gorm:"not null"`
	RefreshTokenExpiration            int                            `gorm:"type:int;not null"`
	EnableLocalLogin                  bool                           `gorm:"not null"`
	AlwaysSendClientClaims            bool                           `gorm:"not null"`
	ClientClaimsPrefix                string                         `gorm:"type:varchar(200)"`
	PairWiseSubjectSalt               string                         `gorm:"type:varchar(200)"`
	UserSsoLifetime                   int                            `gorm:"type:int"`
	LogoutUris                        []ClientPostLogoutRedirectURIs `gorm:"foreignKey:ClientId"`
	Secrets                           []ClientSecrets                `gorm:"foreignKey:ClientId"`
	Origins                           []ClientCorsOrigins            `gorm:"foreignKey:ClientId"`
	Claims                            datatypes.JSON
	Properties                        datatypes.JSON
	IntRecord                         `gorm:"embedded"`
}

Client [...]

func (*Client) GetClientId added in v0.0.2

func (c *Client) GetClientId() string

func (*Client) GetClientName added in v0.0.2

func (c *Client) GetClientName() string

func (*Client) GetGrantTypes added in v0.0.2

func (c *Client) GetGrantTypes() []string

func (*Client) GetPostLogoutUris added in v0.0.2

func (c *Client) GetPostLogoutUris() []string

func (*Client) GetRedirectUris added in v0.0.2

func (c *Client) GetRedirectUris() []string

func (*Client) GetRequireConsent

func (c *Client) GetRequireConsent() bool

func (*Client) GetRequirePKCE added in v0.0.2

func (c *Client) GetRequirePKCE() bool

func (*Client) GetScopes added in v0.0.2

func (c *Client) GetScopes() []string

func (*Client) GetSecret

func (c *Client) GetSecret() []string

GetSecret 方法用于获取当前客户端的密钥。 该方法没有参数。 返回值是一个字符串切片,包含当前客户端的密钥。

func (*Client) GetWebOrigins added in v0.0.2

func (c *Client) GetWebOrigins() []string

func (*Client) SetGrantTypes added in v0.0.2

func (c *Client) SetGrantTypes(val []string)

func (*Client) TableName added in v0.0.2

func (c *Client) TableName() string

type ClientCorsOrigins

type ClientCorsOrigins struct {
	Origin   string `gorm:"type:varchar(150);not null"`
	ClientId int64  `gorm:"index:IX_ClientCorsOrigins_ClientId;type:bigint;not null"`

	IntRecord `gorm:"embedded"`
}

ClientCorsOrigins [...]

type ClientPostLogoutRedirectURIs

type ClientPostLogoutRedirectURIs struct {
	PostLogoutRedirectURI string `gorm:"type:varchar(2000);not null"`
	ClientId              int64  `gorm:"type:bigint;not null"`

	IntRecord `gorm:"embedded"`
}

ClientPostLogoutRedirectURIs [...]

type ClientSecrets

type ClientSecrets struct {
	Name       string    `gorm:"type:varchar(100)"`
	Value      string    `gorm:"type:varchar(256);not null"`
	Expiration time.Time `gorm:"column:expiration;"`

	ClientId  int64 `gorm:"type:varchar(256);not null"`
	IntRecord `gorm:"embedded"`
}

ClientSecrets [...]

type Expression added in v0.0.2

type Expression struct {
	Filter   string
	Column   string
	Value    string
	Operator string

	Children []Expression
}

func (*Expression) IsLogical added in v0.0.2

func (e *Expression) IsLogical() bool

func (*Expression) NewSubExpression added in v0.0.2

func (e *Expression) NewSubExpression() *Expression

type Group added in v0.0.2

type Group struct {
	SnowflakeRecord
	Name        string `json:"name" gorm:"type:varchar(200);not null"`
	Description string `json:"description" gorm:"type:varchar(1000)"`
	Members     []User `gorm:"many2many:user_groups;"`
}

type IntRecord added in v0.0.2

type IntRecord struct {
	Id int64 `json:"id,omitempty" gorm:"primary_key;auto_Increment;not null"`
	Record
}

func (*IntRecord) GetID added in v0.0.2

func (r *IntRecord) GetID() interface{}

type OrganizationUnit

type OrganizationUnit struct {
	Name            string             `json:"name" gorm:" type:varchar(255)"`
	DisplayName     string             `json:"text" gorm:" type:varchar(255)"`
	ParentId        snowflake.ID       `json:"parentId,omitempty" `
	SortOrder       int                `json:"sortorder"`
	Path            string             `json:"path" gorm:"type:varchar(2048)"`
	Children        []OrganizationUnit `json:"nodes" gorm:"foreignkey:ParentId;association_foreignkey:Id"`
	SnowflakeRecord `gorm:"embedded"`
}

func (*OrganizationUnit) GetID

func (m *OrganizationUnit) GetID() interface{}

//TableName 数据表名称

func (m *OrganizationUnit) TableName() string {
	return "OrganizationUnit"
}

func (*OrganizationUnit) ParentID

func (m *OrganizationUnit) ParentID() interface{}
func (m *OrganizationUnit) SetID(id interface{}) {
	m.Id = fmt.Sprintf("%v", id)
}

func (*OrganizationUnit) SetChildren

func (m *OrganizationUnit) SetChildren(children []interface{})

type PersistedGrants

type PersistedGrants struct {
	Principal string `gorm:"primaryKey;type:varchar(200)"`
	ClientId  string `gorm:"primaryKey;type:varchar(200);not null"`
	Scope     string `gorm:"type:text;not null"`
	Record    `gorm:"embedded"`
}

PersistedGrants [...]

func (*PersistedGrants) TableName added in v0.0.2

func (m *PersistedGrants) TableName() string

type Record added in v0.0.2

type Record struct {
	Creator   string    `json:"creator" gorm:"type:varchar(255)"`
	CreatorId string    `json:"creatorId" gorm:"type:varchar(36)"`
	Updator   string    `json:"updator" gorm:"type:varchar(255)"`
	UpdatorId string    `json:"updatorId" gorm:"type:varchar(36)"`
	CreatedAt null.Time `json:"created" gorm:"autoCreateTime"`
	UpdatedAt null.Time `json:"updated" gorm:"autoUpdateTime"`
}

Record 数据库通用结构

func (*Record) BeforeCreate added in v0.0.2

func (r *Record) BeforeCreate(tx *gorm.DB) error

func (*Record) BeforeUpdate added in v0.0.2

func (r *Record) BeforeUpdate(tx *gorm.DB) error

type Role

type Role struct {
	Name            string `gorm:"type:varchar(256);unique"`
	Description     string `gorm:"type:varchar(256)"`
	Users           []User `gorm:"many2many:user_roles;"`
	Claims          datatypes.JSON
	SnowflakeRecord `gorm:"embedded"`
}

Role [...]

func (*Role) GetID

func (r *Role) GetID() interface{}

func (*Role) SetID

func (r *Role) SetID(v interface{})

SetID 获取当前记录的ID

type Scopes added in v0.0.2

type Scopes struct {
	Enabled     bool   `gorm:"not null"`
	Name        string `gorm:"unique;type:varchar(200);not null"` //shold be lower case
	Description string `gorm:"type:varchar(1000)"`
	Properties  datatypes.JSON
	IntRecord   `gorm:"embedded"`
}

oAuth2 Scopes

type SnowflakeRecord added in v0.0.2

type SnowflakeRecord struct {
	Id snowflake.ID `json:"id,omitempty" gorm:"primary_key;not null"`
	Record
}

SnowflakeRecord 数据库通用结构 ID generated by snowflake

func (*SnowflakeRecord) GetID added in v0.0.2

func (r *SnowflakeRecord) GetID() interface{}

type User

type User struct {
	OUId                 snowflake.ID   `json:"ouid" gorm:"column:ou_id;"`
	OU                   string         `json:"ou" gorm:"type:varchar(256)"`
	UserName             string         `json:"userName" gorm:"type:varchar(256)"`
	DisplayName          string         `json:"displayname" gorm:"type:varchar(256)"`
	Email                string         `json:"email" gorm:"type:varchar(256);unique"`
	EmailConfirmed       bool           `json:"emailconfirmed" gorm:"not null"`
	PasswordHash         string         `json:"-" gorm:"type:text"`
	PhoneNumber          string         `json:"phonenumber" gorm:"type:text"`
	PhoneNumberConfirmed bool           `json:"phonenumberconfirmed" gorm:"not null"`
	TwoFactorEnabled     bool           `json:"twofactorenabled" gorm:"not null"`
	IsTemporaryPassword  bool           `json:"istemporarypassword" gorm:"not null"`
	LockoutEnd           null.Time      `json:"lockoutend" gorm:""`
	LockoutEnabled       bool           `json:"lockoutenabled" gorm:"not null"`
	AccessFailedCount    int            `json:"accessfailedcount" gorm:"type:int;"`
	Claims               datatypes.JSON `json:"claims" gorm:"column:claims"`

	SnowflakeRecord `gorm:"embedded"`

	Roles  []Role       `gorm:"many2many:user_roles;"`
	Logins []UserLogins `gorm:"foreignKey:UserId"`
	Groups []Group      `gorm:"many2many:user_groups;"`
}

User 用户信息

func (*User) BeforeCreate

func (r *User) BeforeCreate(tx *gorm.DB) error

func (*User) BeforeUpdate

func (r *User) BeforeUpdate(tx *gorm.DB) error

func (*User) GetEmail added in v0.0.2

func (r *User) GetEmail() string

func (*User) GetId added in v0.0.2

func (m *User) GetId() string

implement base.Row GetID

func (*User) GetPasswordHash added in v0.0.2

func (r *User) GetPasswordHash() string

func (*User) GetUserName added in v0.0.2

func (r *User) GetUserName() string

func (*User) TableName added in v0.0.2

func (m *User) TableName() string

TableName 数据表名称

type UserLogins

type UserLogins struct {
	LoginProvider       string `gorm:"primary_key;type:varchar(255);not null"`
	ProviderKey         string `gorm:"primary_key;type:varchar(255);not null"`
	ProviderDisplayName string `gorm:"type:text"`
	UserId              string `gorm:"index:IX_UserLogins_UserId;type:varchar(255);not null"`
	Record              `gorm:"embedded"`
}

UserLogins [...]

type UserRoles

type UserRoles struct {
	UserId snowflake.ID `gorm:"primary_key;not null"`
	RoleId snowflake.ID `gorm:"primary_key;not null"`
}

UserRoles [...]

type UserTokens

type UserTokens struct {
	LoginProvider string `gorm:"primary_key;type:varchar(255);not null"`
	Name          string `gorm:"primary_key;type:varchar(255);not null"`
	Value         string `gorm:"type:text"`

	Record `gorm:"embedded"`
}

UserTokens [...]

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL