Documentation ¶
Index ¶
- Variables
- func CodeMessage(code MCode) string
- func CountAccounts() (int64, error)
- func CountApplications() (int64, error)
- func PutAccount(model *AccountModel) error
- func PutSession(model *SessionModel) error
- func UnmarshalWebauthnSession(session string) (*webauthn.SessionData, error)
- func UpdateAccountCredentials(model *WebauthnAccount) error
- func UpdateAccountPassword(pk string, password string) error
- func UpdateAccountSession(model *AccountModel, sessionData *webauthn.SessionData) error
- type AccountModel
- type AccountSchema
- type ApplicationModel
- type ClientModel
- func (c *ClientModel) GetAudience() fosite.Arguments
- func (c *ClientModel) GetGrantTypes() fosite.Arguments
- func (c *ClientModel) GetHashedSecret() []byte
- func (c *ClientModel) GetID() string
- func (c *ClientModel) GetRedirectURIs() []string
- func (c *ClientModel) GetResponseTypes() fosite.Arguments
- func (c *ClientModel) GetRotatedHashes() [][]byte
- func (c *ClientModel) GetScopes() fosite.Arguments
- func (c *ClientModel) IsPublic() bool
- type ClientTable
- type CommonResult
- type MCode
- type PermissionModel
- type PermissionSchema
- type RoleModel
- type RoleSchema
- type SessionModel
- type WebauthnAccount
- func (u *WebauthnAccount) AddCredential(cred webauthn.Credential)
- func (u *WebauthnAccount) CredentialExcludeList() []protocol.CredentialDescriptor
- func (model *WebauthnAccount) MarshalCredentials() (string, error)
- func (u *WebauthnAccount) WebAuthnCredentials() []webauthn.Credential
- func (u *WebauthnAccount) WebAuthnDisplayName() string
- func (u *WebauthnAccount) WebAuthnID() []byte
- func (u *WebauthnAccount) WebAuthnIcon() string
- func (u *WebauthnAccount) WebAuthnName() string
- type WebauthnCredentials
Constants ¶
This section is empty.
Variables ¶
View Source
var AccountDataSet = datastore.NewTable[AccountSchema, AccountModel]("accounts", NewAccountSchema())
View Source
var PermissionDataSet = datastore.NewTable[PermissionSchema, PermissionModel]("permissions", NewPermissionSchema())
View Source
var RoleDataSet = datastore.NewTable[RoleSchema, RoleModel]("roles", NewRoleSchema())
Functions ¶
func CodeMessage ¶
func CountAccounts ¶
func CountApplications ¶
func PutAccount ¶
func PutAccount(model *AccountModel) error
func PutSession ¶
func PutSession(model *SessionModel) error
func UnmarshalWebauthnSession ¶
func UnmarshalWebauthnSession(session string) (*webauthn.SessionData, error)
func UpdateAccountCredentials ¶
func UpdateAccountCredentials(model *WebauthnAccount) error
func UpdateAccountPassword ¶
func UpdateAccountSession ¶
func UpdateAccountSession(model *AccountModel, sessionData *webauthn.SessionData) error
Types ¶
type AccountModel ¶
type AccountModel struct { Pk string `json:"pk"` // 主键标识 Username string `json:"username"` // 账号 Password string `json:"-"` // 密码 Photo string `json:"-"` // 密码 CreateTime time.Time `json:"create_time" db:"create_time"` UpdateTime time.Time `json:"update_time" db:"update_time"` Nickname string `json:"nickname"` Mail string `json:"mail"` Credentials string `json:"-"` Session string `json:"-"` Description string `json:"description"` Status int `json:"status"` }
AccountModel 账号模型 table: accounts
func GetAccount ¶
func GetAccount(pk string) (*AccountModel, error)
func GetAccountByUsername ¶
func GetAccountByUsername(username string) (*AccountModel, error)
func NewAccountModel ¶
func NewAccountModel(name string, displayName string) *AccountModel
func SelectAccounts ¶
func SelectAccounts(offset int, limit int) ([]*AccountModel, error)
type AccountSchema ¶
type AccountSchema struct { Pk datastore.ModelCondition Username datastore.ModelCondition Password datastore.ModelCondition Photo datastore.ModelCondition CreateTime datastore.ModelCondition UpdateTime datastore.ModelCondition Nickname datastore.ModelCondition Mail datastore.ModelCondition Credentials datastore.ModelCondition Session datastore.ModelCondition Description datastore.ModelCondition Status datastore.ModelCondition }
func NewAccountSchema ¶
func NewAccountSchema() AccountSchema
func (AccountSchema) GetConditions ¶
func (r AccountSchema) GetConditions() []datastore.ModelCondition
type ApplicationModel ¶
type ApplicationModel struct { Pk string `json:"pk"` // 主键标识 Id string `json:"id"` // 账号 Secret string `json:"-"` RotatedSecrets string `json:"-" db:"rotated_secrets"` RedirectUris string `json:"-" db:"redirect_uris"` ResponseTypes string `json:"-" db:"response_types"` GrantTypes string `json:"-" db:"grant_types"` Scopes string `json:"-"` Audience string `json:"-"` Creator string `json:"creator"` Title string `json:"title"` CreateTime time.Time `json:"create_time" db:"create_time"` UpdateTime time.Time `json:"update_time" db:"update_time"` Description string `json:"description"` }
func GetApplication ¶
func GetApplication(pk string) (*ApplicationModel, error)
func NewApplicationModel ¶
func NewApplicationModel(title string) *ApplicationModel
func SelectApplications ¶
func SelectApplications(offset int, limit int) ([]*ApplicationModel, error)
type ClientModel ¶
type ClientModel struct { ID string `json:"id"` Secret []byte `json:"client_secret,omitempty"` RotatedSecrets [][]byte `json:"rotated_secrets,omitempty"` RedirectURIs []string `json:"redirect_uris"` GrantTypes []string `json:"grant_types"` ResponseTypes []string `json:"response_types"` Scopes []string `json:"scopes"` Audience []string `json:"audience"` Public bool `json:"public"` }
func GetClient ¶
func GetClient(id string) (*ClientModel, error)
func (*ClientModel) GetAudience ¶
func (c *ClientModel) GetAudience() fosite.Arguments
func (*ClientModel) GetGrantTypes ¶
func (c *ClientModel) GetGrantTypes() fosite.Arguments
func (*ClientModel) GetHashedSecret ¶
func (c *ClientModel) GetHashedSecret() []byte
func (*ClientModel) GetID ¶
func (c *ClientModel) GetID() string
func (*ClientModel) GetRedirectURIs ¶
func (c *ClientModel) GetRedirectURIs() []string
func (*ClientModel) GetResponseTypes ¶
func (c *ClientModel) GetResponseTypes() fosite.Arguments
func (*ClientModel) GetRotatedHashes ¶
func (c *ClientModel) GetRotatedHashes() [][]byte
func (*ClientModel) GetScopes ¶
func (c *ClientModel) GetScopes() fosite.Arguments
func (*ClientModel) IsPublic ¶
func (c *ClientModel) IsPublic() bool
type ClientTable ¶
type ClientTable struct { Pk string `json:"pk"` ID string `json:"id"` Secret string `json:"secret"` RotatedSecrets sql.NullString `json:"rotated_secrets" db:"rotated_secrets"` RedirectURIs sql.NullString `json:"redirect_uris" db:"redirect_uris"` GrantTypes sql.NullString `json:"grant_types" db:"grant_types"` ResponseTypes sql.NullString `json:"response_types" db:"response_types"` Scopes sql.NullString `json:"scopes"` Audience sql.NullString `json:"audience"` Public sql.NullInt32 `json:"public"` }
func (*ClientTable) ToModel ¶
func (t *ClientTable) ToModel() *ClientModel
type CommonResult ¶
type CommonResult struct { Code MCode `json:"code"` Message string `json:"message"` Data interface{} `json:"data"` }
func NewCommonResult ¶
func NewCommonResult(code MCode, message string, data interface{}) *CommonResult
func ParseCommonResult ¶
func ParseCommonResult(data interface{}) *CommonResult
func (*CommonResult) SetCode ¶
func (r *CommonResult) SetCode(code MCode) *CommonResult
func (*CommonResult) SetMessage ¶
func (r *CommonResult) SetMessage(message string) *CommonResult
type MCode ¶
type MCode int
func (MCode) ToResult ¶
func (c MCode) ToResult() *CommonResult
func (MCode) WithData ¶
func (c MCode) WithData(data interface{}) *CommonResult
func (MCode) WithError ¶
func (c MCode) WithError(err error) *CommonResult
func (MCode) WithMessage ¶
func (c MCode) WithMessage(message string) *CommonResult
type PermissionModel ¶
type PermissionModel struct { Pk string `json:"pk"` Name string `json:"name"` CreateTime time.Time `json:"create_time" db:"create_time"` UpdateTime time.Time `json:"update_time" db:"update_time"` Description string `json:"description"` }
PermissionModel 权限模型 table: permissions
type PermissionSchema ¶
type PermissionSchema struct { Pk datastore.ModelCondition Name datastore.ModelCondition CreateTime datastore.ModelCondition UpdateTime datastore.ModelCondition Description datastore.ModelCondition }
func NewPermissionSchema ¶
func NewPermissionSchema() PermissionSchema
func (PermissionSchema) GetConditions ¶
func (r PermissionSchema) GetConditions() []datastore.ModelCondition
type RoleModel ¶
type RoleModel struct { Pk string `json:"pk"` Name string `json:"name"` CreateTime time.Time `json:"create_time" db:"create_time"` UpdateTime time.Time `json:"update_time" db:"update_time"` Description string `json:"description"` }
RoleModel table: roles
type RoleSchema ¶
type RoleSchema struct { Pk datastore.ModelCondition Name datastore.ModelCondition CreateTime datastore.ModelCondition UpdateTime datastore.ModelCondition Description datastore.ModelCondition }
func NewRoleSchema ¶
func NewRoleSchema() RoleSchema
func (RoleSchema) GetConditions ¶
func (r RoleSchema) GetConditions() []datastore.ModelCondition
type SessionModel ¶
type SessionModel struct { Pk string `json:"pk"` Content string `json:"content"` CreateTime time.Time `json:"create_time" db:"create_time"` UpdateTime time.Time `json:"update_time" db:"update_time"` User string `json:"user"` Type string `json:"type"` Code sql.NullString `json:"code"` }
func GetSession ¶
func GetSession(pk string) (*SessionModel, error)
type WebauthnAccount ¶
type WebauthnAccount struct { AccountModel WebauthnCredentials }
func CopyWebauthnAccount ¶
func CopyWebauthnAccount(account *AccountModel) *WebauthnAccount
func NewWebauthnAccount ¶
func NewWebauthnAccount(name string, displayName string) *WebauthnAccount
func (*WebauthnAccount) AddCredential ¶
func (u *WebauthnAccount) AddCredential(cred webauthn.Credential)
AddCredential associates the credential to the user
func (*WebauthnAccount) CredentialExcludeList ¶
func (u *WebauthnAccount) CredentialExcludeList() []protocol.CredentialDescriptor
CredentialExcludeList returns a CredentialDescriptor array filled with all the user's credentials
func (*WebauthnAccount) MarshalCredentials ¶
func (model *WebauthnAccount) MarshalCredentials() (string, error)
func (*WebauthnAccount) WebAuthnCredentials ¶
func (u *WebauthnAccount) WebAuthnCredentials() []webauthn.Credential
WebAuthnCredentials returns credentials owned by the user
func (*WebauthnAccount) WebAuthnDisplayName ¶
func (u *WebauthnAccount) WebAuthnDisplayName() string
WebAuthnDisplayName returns the user's display name
func (*WebauthnAccount) WebAuthnID ¶
func (u *WebauthnAccount) WebAuthnID() []byte
WebAuthnID returns the user's ID
func (*WebauthnAccount) WebAuthnIcon ¶
func (u *WebauthnAccount) WebAuthnIcon() string
WebAuthnIcon is not (yet) implemented
func (*WebauthnAccount) WebAuthnName ¶
func (u *WebauthnAccount) WebAuthnName() string
WebAuthnName returns the user's username
type WebauthnCredentials ¶
type WebauthnCredentials struct {
CredentialsSlice []webauthn.Credential
}
Click to show internal directories.
Click to hide internal directories.