Documentation
¶
Index ¶
Constants ¶
const ( ValidateClientValid = 0x0 ValidateClientNilUID = 0x1 ValidateClientEmptyName = 0x2 ValidateClientNameTooLong = 0x4 ValidateClientEmptyRedirectUrl = 0x8 ValidateClientRedirectUrlTooLong = 0x10 ValidateClientInvalidRedirectUrl = 0x20 ValidateClientInvalidTokenType = 0x40 ValidateClientEmptyKeyUri = 0x80 ValidateClientKeyUriTooLong = 0x100 )
const ( ClientTokenTypeDefault = iota ClientTokenTypeFirebase = iota )
const ( ValidateMigrationValid = 0x0 ValidateMigrationInvalidTimestamp = 0x1 )
const ( ValidateSessionValid = 0x0 ValidateSessionNilToken = 0x1 )
const ( ValidateUserValid = 0x0 ValidateUserEmptyUsername = 0x1 ValidateUserUsernameTooLong = 0x2 ValidateUserInvalidRank = 0x8 )
const ( ValidateUserRoleValid = 0x0 ValidateUserRoleEmptyRole = 0x1 ValidateUserRoleRoleTooLong = 0x2 )
const ClientKeyUriMaxLength = 100
ClientKeyUriMaxLength is the max length a client's key uri can be.
const ClientNameMaxLength = 30
ClientNameMaxLength is the max length a client's name can be.
const ClientRedirectUrlMaxLength = 100
ClientRedirectUrlMaxLength is the max length a client's redirect url can be.
const UserRoleRoleMaxLength = 15
UserRoleRoleMaxLength is the max length a user's username can be.
const UserUsernameMaxLength = 30
UserUsernameMaxLength is the max length a user's username can be.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { UID uuid.UUID `firestore:"uid"` Name string `firestore:"name"` RedirectUrl string `firestore:"redirect_url"` TokenType int `firestore:"token_type"` KeyUri string `firestore:"key_uri"` }
Client represents the client model.
func CreateClient ¶
func CreateClient(uid uuid.UUID, name string, redirectUrl string, tokenType int, keyUri string) *Client
CreateClient creates a new client model with the provided fields.
func CreateNewClient ¶
CreateNewClient generates a new uid then creates a new client model with the uid and provided fields.
type ClientCRUD ¶
type ClientCRUD interface { // CreateClient creates a new client and returns any errors. CreateClient(client *Client) error // GetClients fetches all the clients. // Returns the clients and any errors. GetClients() ([]*Client, error) // GetClientByUID fetches the client associated with the uid. // If no clients are found, returns nil client. Also returns any errors. GetClientByUID(uid uuid.UUID) (*Client, error) // UpdateClient updates the client. // Returns result of whether the client was found, and any errors. UpdateClient(client *Client) (bool, error) // DeleteClient deletes the client the with the given uid. // Returns result of whether the client was found, and any errors. DeleteClient(uid uuid.UUID) (bool, error) }
type Migration ¶
type Migration struct {
Timestamp string `firestore:"timestamp"`
}
Migration represents the migration model.
func CreateMigration ¶
CreateMigration creates a new migration model with the provided fields.
type MigrationCRUD ¶
type MigrationCRUD interface { migrationrunner.MigrationCRUD // GetMigrationByTimestamp fetches the migration with the matching timestamp. // If no migrations are found, returns nil migration. Also returns any errors. GetMigrationByTimestamp(timestamp string) (*Migration, error) }
type Session ¶
type Session struct { Token uuid.UUID `firestore:"token"` Username string `firestore:"username"` Rank int `firestore:"rank"` }
Session represents the session model.
func CreateNewSession ¶
CreateNewSession generates a new token then creates a new session model with the token and provided field.
func CreateSession ¶
CreateSession creates a new session model with the provided field.
type SessionCRUD ¶
type SessionCRUD interface { // SaveSession saves the session and returns any errors. SaveSession(session *Session) error // GetSessionByToken fetches the session with the given token. // If no sessions are found, returns nil session. // Also returns any errors. GetSessionByToken(token uuid.UUID) (*Session, error) // DeleteSession deletes the session with the given token. // Returns result of whether the session was found, and any errors. DeleteSession(token uuid.UUID) (bool, error) // DeleteAllOtherUserSessions deletes all of the sessions for the given username. // Returns any errors. DeleteAllUserSessions(username string) error // DeleteAllOtherUserSessions deletes all of the sessions for the given username except the one with the given token. // Returns any errors. DeleteAllOtherUserSessions(username string, tokem uuid.UUID) error }
type User ¶
type User struct { Username string `firestore:"username"` Rank int `firestore:"rank"` PasswordHash []byte `firestore:"password_hash"` }
User represents the user model.
func CreateUser ¶
CreateUser creates a new user model with the provided fields.
type UserCRUD ¶
type UserCRUD interface { // CreateUser creates a new user and returns any errors. CreateUser(user *User) error // GetUsersWithLesserRank fetches all the users with a rank less than the provided one. // Returns the users and any errors. GetUsersWithLesserRank(rank int) ([]*User, error) // GetUserByUsername fetches the user with the matching username. // If no users are found, returns nil user. Also returns any errors. GetUserByUsername(username string) (*User, error) // UpdateUser updates the user. // Returns result of whether the user was found, and any errors. UpdateUser(user *User) (bool, error) // UpdateUserPassword updates the user's password. // Returns result of whether the user was found, and any errors. UpdateUserPassword(username string, hash []byte) (bool, error) // DeleteUser deletes the user with the given username. // Returns result of whether the user was found, and any errors. DeleteUser(username string) (bool, error) }
type UserRole ¶
type UserRole struct { ClientUID uuid.UUID `firestore:"client_uid"` Username string `firestore:"username"` Role string `firestore:"role"` }
UserRole represents the user-role model.
func CreateUserRole ¶
CreateUserRole creates a new user-role model with the provided fields.
type UserRoleCRUD ¶
type UserRoleCRUD interface { // CreateUserRole creates the user-role. Returns any errors. CreateUserRole(role *UserRole) error // GetUserRolesWithLesserRankByClientUID fetches the user-roles for the provided client uid and with a rank less than the provided rank. // Returns the user-roles and returns any errors. GetUserRolesWithLesserRankByClientUID(uid uuid.UUID, rank int) ([]*UserRole, error) // GetUserRoleByClientUIDAndUsername fetches the user-role for the provided client uid and username. // Returns the user-role if it exists, nil if not. Also returns any errors. GetUserRoleByClientUIDAndUsername(clientUID uuid.UUID, username string) (*UserRole, error) // UpdateUserRole updates the user-role. // Returns result of whether the user-role was found and any errors. UpdateUserRole(role *UserRole) (bool, error) // DeleteUserRole deletes the user-role with the given client uid and username. // Returns result of whether the user-role was found, and any errors. DeleteUserRole(clientUID uuid.UUID, username string) (bool, error) }