Documentation ¶
Index ¶
- Constants
- Variables
- func IP(r *http.Request) string
- type Current
- type DisplayName
- type Email
- type Group
- type GroupCreationRequest
- type GroupProvider
- type Hash
- type LoginRequest
- type LoginResponse
- type LoginResult
- type Me
- type Providers
- type Session
- type SessionInfo
- type SessionProvider
- type User
- type UserGroup
- type UserGroupProvider
- type UserInfo
- type UserProvider
- type UserSearcher
- type Users
Constants ¶
const ( BuiltInGroupAdmin = "ADMIN" BuiltInGroupSpouse = "SPOUSE" BuiltInGroupResident = "RESIDENT" BuiltInGroupFriend = "FRIEND" BuiltInGroupPowerUser = "POWER_USER" BuiltInGroupUser = "USER" )
const ( PermissionResetUserPassword = "RESET_USER_PASSWORD" PermissionSetAdmin = "SET_ADMIN" PermissionProxyAsUser = "PROXY_AS_USER" PermissionViewAppSettings = "VIEW_APP_SETTINGS" PermissionChangeAppSettings = "CHANGE_APP_SETTINGS" PermissionManageAppDeployment = "MANAGE_APP_DEPLOYMENT" PermissionStopServer = "STOP_SERVER" PermissionManageIndexes = "MANAGE_INDEXES" PermissionLogging = "LOGGING" )
Elevated permissions
const ( PermissionPostComments = "POST_COMMENTS" PermissionEditUserInfo = "EDIT_USER_INFO" PermissionUnlockUser = "UNLOCK_USER" PermissionViewUsers = "VIEW_USERS" PermissionEditGroups = "EDIT_GROUPS" PermissionViewGroups = "VIEW_GROUPS" PermissionManageIOTDevices = "MANAGE_IOT_DEVICES" )
const ( PermissionListProjects = "LIST_PROJECTS" PermissionViewEchoHistory = "VIEW_ECHO_HISTORY" )
Projects Module
const GroupPrefix = "GROUP:"
const (
PermissionSetDefaultParty = "SET_DEFAULT_PARTY"
)
Visit module
const SessionPrefix = "SESSION:"
const UserGroupPrefix = "USERGROUP:"
const UserPrefix = "USER:"
Variables ¶
var Permissions = []string{ PermissionResetUserPassword, PermissionSetAdmin, PermissionProxyAsUser, PermissionViewAppSettings, PermissionChangeAppSettings, PermissionManageAppDeployment, PermissionStopServer, PermissionManageIndexes, PermissionLogging, PermissionPostComments, PermissionEditUserInfo, PermissionUnlockUser, PermissionViewUsers, PermissionEditGroups, PermissionViewGroups, PermissionManageIOTDevices, PermissionSetDefaultParty, PermissionListProjects, PermissionViewEchoHistory, }
Functions ¶
Types ¶
type Current ¶
type Current struct { User UserInfo `json:"user"` Session Session `json:"session"` // contains filtered or unexported fields }
Current holds details about the current user. The zero value is an anonymous user.
func GetCurrent ¶
GetCurrent returns details about the current user based upon the token provided. If the token is empty or there is an error getting this information, the current values will be for the anonymous user.
func (Current) Anonymous ¶ added in v0.3.0
Anonymous returns whether the current user ID is 0, the anonymous user
func (Current) Authenticated ¶
Authenticated returns whether the current user is not anonymous by checking that the user id is non-zero
func (Current) Can ¶
Can asks if a user can do something. It returns nil if a user is in a group with the specified permission. Admins always return nil because they can do anything. Otherwise can returns an appropriate StatusError.
if err := cur.Can(core.PermissionViewAppSettings); err != nil { return err }
type DisplayName ¶
type DisplayName string
func (DisplayName) Tag ¶
func (d DisplayName) Tag() string
type Group ¶
type Group struct { Name string `json:"name"` Permissions []string `json:"permissions"` Requires2FA bool `json:"requires2FA"` RequiresVaultPIN bool `json:"requiresVaultPIN"` ModifiedBy store.Identity `json:"modifiedBy"` ModifiedDate time.Time `json:"modifiedDate"` }
func (Group) HasPermission ¶
type GroupCreationRequest ¶
type GroupProvider ¶
type LoginRequest ¶
type LoginResponse ¶ added in v0.3.0
type LoginResponse struct { LoginResult LoginResult `json:"loginResult"` IntermediateToken *string `json:"intermediateToken,omitempty"` Me *Me `json:"me,omitempty"` }
type LoginResult ¶
type LoginResult int
const ( LoginResultSuccess LoginResult = iota // 0 LoginResultBadCredentials // 1 LoginResultEmailNotVerified // 2 LoginResult2FA // 3 LoginResultChangePassword // 4 LoginResultLockedOrDisabled // 5 LoginResultError // 6 )
type Providers ¶
type Providers struct { Sessions SessionProvider Users UserProvider Groups GroupProvider UserGroups UserGroupProvider }
type Session ¶
type Session struct { Token string `json:"token"` UserID store.Identity `json:"userID"` IP string `json:"ip"` Proxy bool `json:"proxy"` VaultUnlocked bool `json:"vaultUnlocked"` CreatedDate time.Time `json:"createdDate"` Heartbeat time.Time `json:"heartbeat"` }
func (Session) Info ¶ added in v0.3.0
func (s Session) Info() SessionInfo
type SessionInfo ¶ added in v0.3.0
type SessionProvider ¶
type SessionProvider interface { Get(token string) (Session, error) Exists(token string) (bool, error) Set(session Session) error GenerateFor(userID store.Identity, ip string) Session All() ([]Session, error) Delete(token string) error PurgeAll() error UpdateHeartbeat(session *Session, ip string) error DoLogin(req LoginRequest, ip string) (UserInfo, Session, LoginResult, error) }
type User ¶
type User struct { ID store.Identity `json:"id"` GoogleID string `json:"googleId"` GoogleImportDate time.Time `json:"googleImportDate"` PrimaryEmail string `json:"primaryEmail"` Emails []Email `json:"emails"` Tag string `json:"tag"` PreviousTags []string `json:"previousTags"` PasswordHash Hash `json:"-"` LastPasswordHash Hash `json:"-"` MustChangePWNextLogin bool `json:"mustChangePWNextLogin"` Require2FA bool `json:"require2FA"` VaultPIN string `json:"-"` Locked bool `json:"locked"` Disabled bool `json:"disabled"` LoginAttempts int `json:"loginAttempts"` LastFailedLogin time.Time `json:"lastFailedLogin"` DisplayName DisplayName `json:"displayName"` GivenName string `json:"givenName"` FamilyName string `json:"familyName"` Link string `json:"link"` Picture string `json:"picture"` Gender string `json:"gender"` Locale string `json:"locale"` LastLogin time.Time `json:"lastLogin"` ModifiedDate time.Time `json:"modifiedDate"` CreatedDate time.Time `json:"createdDate"` }
type UserGroup ¶
type UserGroupProvider ¶
type UserProvider ¶
type UserSearcher ¶
type UserSearcher interface { Index(u User) error Deindex(u User) error Reindex() error CompletionSuggestions(query string) ([]User, error) FromEmail(email string) (User, error) WithEmail(email string) ([]User, error) EmailExists(email string) (bool, error) VerifiedEmailExists(email string) (bool, error) }