Documentation ¶
Index ¶
- Constants
- Variables
- type API
- func (a *API) AddRole(r *http.Request, role string) error
- func (a *API) Can(r *http.Request, action, target string) (bool, error)
- func (a *API) ChangeEmail(id, newEmail string) error
- func (a *API) ClearRoles(r *http.Request) error
- func (a *API) ConfirmEmail(token string) error
- func (a *API) ConfirmEmailChange(token string) error
- func (a *API) ConfirmRecovery(token, password string) error
- func (a *API) DelSessionVal(r *http.Request, w http.ResponseWriter, key string) error
- func (a *API) DeleteMetaDataKeys(r *http.Request, keys []string) error
- func (a *API) DeleteRole(r *http.Request, role string) error
- func (a *API) DeleteUser(r *http.Request) error
- func (a *API) GetRoles(r *http.Request) ([]string, error)
- func (a *API) GetSessionStringVal(r *http.Request, key string) *string
- func (a *API) GetSessionVal(r *http.Request, key string) (interface{}, error)
- func (a *API) GetWorkspaceRole(r *http.Request, workspaceID string) (string, error)
- func (a *API) HandleGothCallback(w http.ResponseWriter, r *http.Request, role string, ...) error
- func (a *API) HandleGothLogin(w http.ResponseWriter, r *http.Request) error
- func (a *API) HandleGothLogout(w http.ResponseWriter, r *http.Request) error
- func (a *API) InviteGuests(r *http.Request, workspaceID string, guests []string) error
- func (a *API) IsAuthenticated(next http.Handler) http.Handler
- func (a *API) LoggedInUser(r *http.Request) (*User, error)
- func (a *API) Login(w http.ResponseWriter, r *http.Request, email, password string) error
- func (a *API) LoginWithOTP(w http.ResponseWriter, r *http.Request, otp string) error
- func (a *API) Logout(w http.ResponseWriter, r *http.Request)
- func (a *API) OTP(email string) error
- func (a *API) Recovery(email string) error
- func (a *API) ResetAPIToken(r *http.Request) (string, error)
- func (a *API) SetSessionVal(r *http.Request, w http.ResponseWriter, key string, val interface{}) error
- func (a *API) Signup(email, password, role string, metadata map[string]interface{}) error
- func (a *API) UpdateBillingID(r *http.Request, billingID string) error
- func (a *API) UpdateMetaData(r *http.Request, metaData map[string]interface{}) error
- type Config
- type MailType
- type Permission
- type SendMailFunc
- type SessionsStore
- type User
- type UserStore
- type Workspace
- type WorkspaceStore
Constants ¶
View Source
const (
CtxUserIdKey = "key_user_id"
)
Variables ¶
View Source
var ( ErrInvalidPassword = errors.New("password is invalid") ErrWrongPassword = errors.New("password is wrong") ErrInvalidEmail = errors.New("email is invalid") ErrUserNotFound = errors.New("user not found") ErrUserNotLoggedIn = errors.New("user is not logged in") ErrEmailNotConfirmed = errors.New("email has not been confirmed") ErrLoginSessionNotFound = errors.New("a valid login session wasn't found") ErrSessionValNotFound = errors.New("session val not found") ErrInternal = errors.New("internal server error") ErrUserExists = errors.New("email is already linked to a user") ErrSendingEmail = errors.New("problem sending the email") )
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
func NewAPI ¶
func NewAPI(ctx context.Context, apiMasterSecret string, userStore UserStore, sessionStore SessionsStore, workspaceStore WorkspaceStore, sendMail SendMailFunc, roles map[string][]Permission) *API
func (*API) ChangeEmail ¶
func (*API) ConfirmEmail ¶
func (*API) ConfirmEmailChange ¶
func (*API) ConfirmRecovery ¶
func (*API) DelSessionVal ¶
func (*API) DeleteMetaDataKeys ¶
func (*API) DeleteRole ¶ added in v0.1.5
func (*API) GetSessionStringVal ¶ added in v0.1.3
func (*API) GetSessionVal ¶
func (*API) GetWorkspaceRole ¶ added in v0.1.7
func (*API) HandleGothCallback ¶
func (*API) HandleGothLogin ¶
func (*API) HandleGothLogout ¶
func (*API) InviteGuests ¶ added in v0.1.7
func (*API) LoginWithOTP ¶
func (*API) SetSessionVal ¶
func (*API) UpdateBillingID ¶ added in v0.1.2
type Config ¶
type Config struct { Driver string Datasource string SessionSecret string SendMail SendMailFunc APIMasterSecret string GothProviders []goth.Provider Roles map[string][]Permission }
type Permission ¶ added in v0.1.5
type Permission struct { ActionMatcher rbac.Matcher TargetMatcher func(userID string) rbac.Matcher }
func NewPermission ¶ added in v0.1.6
func NewPermission(action string, targetMatcher func(userID string) rbac.Matcher) Permission
type SendMailFunc ¶
type SessionsStore ¶
func NewDefaultSessionStore ¶
type UserStore ¶
type UserStore interface { // Create, Delete New(email, password, role, provider string, meta map[string]interface{}, sendMailFunc func(string, string) error) (string, error) UserData(id string) (string, string, string, map[string]interface{}, error) UserIDByEmail(email string) (string, error) UserIDByConfirmationToken(token string) (string, error) UserIDByRecoveryToken(token string) (string, error) UserIDByEmailChangeToken(token string) (string, error) UserIDByOTP(token string) (string, error) UserIDByAPIKey(apiKey string) (string, error) DeleteUser(id string) error GetPassword(id string) (string, error) GetAPIKey(id string) (string, error) GetEmailChange(id string) (string, error) IsEmailConfirmed(id string) (bool, error) GetRoles(id string) ([]string, error) AddRole(id, role string) error DeleteRole(id, role string) error ClearRoles(id string) error // Update Password UpdatePassword(id, password string) error // Update API Key UpdateAPIKey(id, apiKey string) error // Update Email UpdateEmail(id, email string) error UpdateBillingID(id, billingID string) error UpdateProvider(id, provider string) error // Confirm Email SaveConfirmationToken(id, token string) error SaveConfirmationTokenSentAt(id string, tokenSentAt time.Time) error MarkConfirmed(id string, confirmed bool) error DeleteConfirmToken(id string) error // One time password SaveOTP(id, otp string) error SaveOTPSentAt(id string, otpSentAt time.Time) error DeleteOTP(id string) error // Recover Password SaveRecoveryToken(id, token string) error SaveRecoveryTokenSentAt(id string, tokenSentAt time.Time) error DeleteRecoveryToken(id string) error // Change Email SaveEmailChangeToken(id, email, token string) error SaveEmailChangeTokenSentAt(id string, tokenSentAt time.Time) error DeleteEmailChangeToken(id string) error // Metadata UpsertMetaData(id string, metaData map[string]interface{}) error DeleteKeysMetaData(id string, keys []string) error DeleteAllMetadata(id string) error // Timestamps SetUpdatedAt(id string, time time.Time) error SetLastSignInAt(id string, time time.Time) error Close() error }
UserStore represents the data store for the User model
type WorkspaceStore ¶ added in v0.1.7
type WorkspaceStore interface { GetWorkspace(id string) (string, string, map[string]interface{}, error) CreateWorkspace(userID, name, description, plan string, metadata map[string]interface{}) (string, error) UpdateWorkspace(workspaceID, name, description, plan string, metadata map[string]interface{}) error DeleteWorkspace(workspaceID string) error GetUserWorkspaces(userID string) (map[string][]string, error) WorkspaceUpsertUser(workspaceID, userID, role string) error WorkspaceRemoveUser(workspaceID, userID string) error GetWorkspaceGroups(workspaceID string) ([]string, error) GetGroup(id string) (string, string, map[string]interface{}, error) CreateGroup(userID, workspaceID, name, description string, metadata map[string]interface{}) (string, error) UpdateGroup(groupID, name, description string, metadata map[string]interface{}) error DeleteGroup(groupID string) error GetUserGroupRoles(userID string) (map[string]string, error) GroupUpsertUser(groupID, userID, role string) error GroupRemoveUser(groupID, userID string) error CreatePermission(roleID, action, target string) error UpdatePermission(roleID, action, target string) error DeletePermission(roleID, action string) error GetUserPermissions(userID string) (map[string]string, error) GetUserRoles(userID string) ([]string, error) CreateUserRole(userID, role string) error DeleteUserRole(userID, role string) error }
func NewDefaultWorkspaceStore ¶ added in v0.1.7
func NewDefaultWorkspaceStore(ctx context.Context, driver, dataSource string) (WorkspaceStore, error)
Click to show internal directories.
Click to hide internal directories.