Documentation
¶
Index ¶
- Variables
- func GetTimeUTCPointer() *time.Time
- func IsUnixZero(t time.Time) bool
- func RandString(n int) string
- func TimeToPointer(t time.Time) *time.Time
- func UnixToTimePointer(v int64) *time.Time
- type DBConf
- type Database
- type OAuthClient
- type OAuthClientData
- type OAuthClientsStore
- type OAuthToken
- type OAuthTokenData
- type OAuthTokensStore
- func (s *OAuthTokensStore) Create(ctx context.Context, info oauth2.TokenInfo) error
- func (s *OAuthTokensStore) FindAll(cond db.Cond) ([]*OAuthToken, error)
- func (s *OAuthTokensStore) FindOne(cond db.Cond) (oauth2.TokenInfo, error)
- func (s *OAuthTokensStore) GetByAccess(ctx context.Context, access string) (oauth2.TokenInfo, error)
- func (s *OAuthTokensStore) GetByCode(ctx context.Context, code string) (oauth2.TokenInfo, error)
- func (s *OAuthTokensStore) GetByRefresh(ctx context.Context, refresh string) (oauth2.TokenInfo, error)
- func (s *OAuthTokensStore) RemoveByAccess(ctx context.Context, access string) error
- func (s *OAuthTokensStore) RemoveByCode(ctx context.Context, code string) error
- func (s *OAuthTokensStore) RemoveByRefresh(ctx context.Context, refresh string) error
- type User
- type UserEtc
- type UserRole
- type UsersStore
- func (store UsersStore) FindAll(cond ...interface{}) ([]*User, error)
- func (store UsersStore) FindByAlias(alias string) (*User, error)
- func (store UsersStore) FindByEmail(email string) (*User, error)
- func (store UsersStore) FindByID(ID int64) (*User, error)
- func (store UsersStore) FindOne(cond ...interface{}) (*User, error)
Constants ¶
This section is empty.
Variables ¶
var (
ErrInvalidOAuthClient = errors.New("invalid oauth client type")
)
var (
ErrInvalidOAuthInfo = errors.New("invalid oauth TokenInfo type")
)
Functions ¶
func GetTimeUTCPointer ¶
GetTimeUTCPointer gets utc time pointer
func IsUnixZero ¶
func RandString ¶
RandString generates random sting from characters in letters
func UnixToTimePointer ¶
Types ¶
type DBConf ¶
type DBConf struct { Database string `toml:"database"` Hosts []string `toml:"hosts"` Username string `toml:"username"` Password string `toml:"password"` DebugQueries bool `toml:"debug_queries"` ApplicationName string `toml:"application_name"` MaxConnection int `toml:"max_connection"` SSLMode string `toml:"ssl_mode"` DatabaseURL string `env:"DATABASE_URL"` }
DBConf database configuration
type Database ¶
type Database struct { db.Session OAuthToken *OAuthTokensStore OAuthClient *OAuthClientsStore User *UsersStore }
Database holds database postgres table structure
var DB *Database
DB is a pointer to the database interface
type OAuthClient ¶
type OAuthClient struct { ID string `db:"id,omitempty"` Secret string `db:"secret"` Domain string `db:"domain"` Data OAuthClientData `db:"data"` }
func (*OAuthClient) Store ¶
func (u *OAuthClient) Store(sess db.Session) db.Store
type OAuthClientData ¶
type OAuthClientData struct { *models.Client *postgresql.JSONBConverter }
type OAuthClientsStore ¶
type OAuthClientsStore struct {
db.Collection
}
OAuthClientsStore holds oauth_tokens database collection
func OAuthClients ¶
func OAuthClients(sess db.Session) *OAuthClientsStore
func (*OAuthClientsStore) Create ¶
func (s *OAuthClientsStore) Create(info oauth2.ClientInfo) error
Create creates and stores the new client information
func (*OAuthClientsStore) FindOne ¶
func (s *OAuthClientsStore) FindOne(cond db.Cond) (oauth2.ClientInfo, error)
find one client
type OAuthToken ¶
type OAuthToken struct { ID int64 `db:"id,omitempty"` CreatedAt *time.Time `db:"created_at"` ExpiresAt time.Time `db:"expires_at"` Code string `db:"code"` Access string `db:"access"` Refresh string `db:"refresh"` Data OAuthTokenData `db:"data"` }
func (*OAuthToken) BeforeCreate ¶
func (u *OAuthToken) BeforeCreate(sess db.Session) error
BeforeCreate retrives and sets GetTimeUTCPointer before creating a new oauth token
func (*OAuthToken) Store ¶
func (u *OAuthToken) Store(sess db.Session) db.Store
type OAuthTokenData ¶
type OAuthTokenData struct { *models.Token *postgresql.JSONBConverter }
type OAuthTokensStore ¶
type OAuthTokensStore struct {
db.Collection
}
OAuthTokensStore holds oauth_tokens database collection
func OAuthTokens ¶
func OAuthTokens(sess db.Session) *OAuthTokensStore
func (*OAuthTokensStore) Create ¶
func (s *OAuthTokensStore) Create(ctx context.Context, info oauth2.TokenInfo) error
create and store the new token information
func (*OAuthTokensStore) FindAll ¶
func (s *OAuthTokensStore) FindAll(cond db.Cond) ([]*OAuthToken, error)
find all token
func (*OAuthTokensStore) FindOne ¶
func (s *OAuthTokensStore) FindOne(cond db.Cond) (oauth2.TokenInfo, error)
find one token
func (*OAuthTokensStore) GetByAccess ¶
func (s *OAuthTokensStore) GetByAccess(ctx context.Context, access string) (oauth2.TokenInfo, error)
use the access token for token information data
func (*OAuthTokensStore) GetByCode ¶
func (s *OAuthTokensStore) GetByCode(ctx context.Context, code string) (oauth2.TokenInfo, error)
use the authorization code for token information data
func (*OAuthTokensStore) GetByRefresh ¶
func (s *OAuthTokensStore) GetByRefresh(ctx context.Context, refresh string) (oauth2.TokenInfo, error)
use the refresh token for token information data
func (*OAuthTokensStore) RemoveByAccess ¶
func (s *OAuthTokensStore) RemoveByAccess(ctx context.Context, access string) error
use the access token to delete the token information
func (*OAuthTokensStore) RemoveByCode ¶
func (s *OAuthTokensStore) RemoveByCode(ctx context.Context, code string) error
delete the authorization code
func (*OAuthTokensStore) RemoveByRefresh ¶
func (s *OAuthTokensStore) RemoveByRefresh(ctx context.Context, refresh string) error
use the refresh token to delete the token information
type User ¶
type User struct { ID int64 `db:"id,omitempty" json:"id"` Email string `db:"email,omitempty" json:"email"` PasswordHash string `db:"password_hash,omitempty" json:"-"` Role UserRole `db:"role" json:"role"` FirstName string `db:"first_name,omitempty" json:"firstName"` LastName string `db:"last_name,omitempty" json:"lastName"` Location string `db:"location,omitempty" json:"location"` Etc UserEtc `db:"etc,omitempty" json:"etc"` CreatedAt *time.Time `db:"created_at,omitempty" json:"createdAt"` UpdatedAt *time.Time `db:"updated_at,omitempty" json:"updatedAt"` // Display Only Biography string `json:"biography"` Name string `json:"name"` }
User holds postgres data structure for user
func (*User) BeforeCreate ¶
BeforeCreate retrives and sets GetTimeUTCPointer before creating a new user
func (*User) BeforeUpdate ¶
BeforeUpdate retrives and sets GetTimeUTCPointer before updating a user
type UserEtc ¶
type UserEtc struct { HasProfile bool *postgresql.JSONBConverter }
UserEtc is a collection of auxillary key/values around a user
type UsersStore ¶
type UsersStore struct {
db.Collection
}
UsersStore holds thread users database collection
func (UsersStore) FindAll ¶
func (store UsersStore) FindAll(cond ...interface{}) ([]*User, error)
FindAll retrieves users by certain conditions from UsersStore
func (UsersStore) FindByAlias ¶
func (store UsersStore) FindByAlias(alias string) (*User, error)
FindByAlias retrieves a particular user by alias
func (UsersStore) FindByEmail ¶
func (store UsersStore) FindByEmail(email string) (*User, error)
FindByEmail retrieves a particular user by email
func (UsersStore) FindByID ¶
func (store UsersStore) FindByID(ID int64) (*User, error)
FindByID retrieves a particular user by id
func (UsersStore) FindOne ¶
func (store UsersStore) FindOne(cond ...interface{}) (*User, error)
FindOne retrieves user by certain conditions from UsersStore