Documentation ¶
Index ¶
- Constants
- Variables
- func HashPassword(in string) string
- func UserNameToKey(name string) string
- type Access
- type AccessWithKey
- type Server
- type Session
- type Settings
- func (s *Settings) AccessList(name string) map[string]Access
- func (s *Settings) CopyFrom(other *Settings)
- func (s *Settings) CreateSession(userName string) tid.TID
- func (s *Settings) CreateUser(name, password string) bool
- func (s *Settings) LookupSession(id tid.TID) (string, bool)
- func (s *Settings) LookupUserNameAndPassword(name string) (actualName, hashedPassword string, ok bool)
- func (s *Settings) MarshalJSON() ([]byte, error)
- func (s *Settings) PruneSessions()
- func (s *Settings) RemoveSession(id tid.TID)
- func (s *Settings) RemoveUser(name string)
- func (s *Settings) RenameUser(oldName, newName string) bool
- func (s *Settings) Save(filePath string) error
- func (s *Settings) SetAccessList(name string, accessList map[string]Access)
- func (s *Settings) SetUserPassword(name, password string) bool
- func (s *Settings) UnmarshalJSON(data []byte) error
- func (s *Settings) Users() []*User
- func (s *Settings) Valid() bool
- func (s *Settings) Validate()
- type User
Constants ¶
const ( MaxSessionDuration = time.Hour * 24 * 30 SessionGracePeriod = time.Minute * 10 )
Constants
Variables ¶
var ( DefaultShutdownGracePeriod = fxp.Ten DefaultReadTimeout = fxp.Ten DefaultWriteTimeout = fxp.Thirty DefaultIdleTimeout = fxp.Sixty MinimumTimeout = fxp.One MaximumTimeout = fxp.SixHundred DefaultAddress = "localhost:8422" )
Minimums and defaults for web server settings.
Functions ¶
func UserNameToKey ¶
UserNameToKey converts a user name to a key.
Types ¶
type Access ¶
Access holds the configuration for a user's access to a directory (and all of its sub-paths) on the server.
type AccessWithKey ¶
AccessWithKey holds the configuration for a user's access to a directory (and all of its sub-paths) on the server and also includes the key by which it is referenced.
func (*AccessWithKey) String ¶
func (a *AccessWithKey) String() string
type Server ¶
type Server struct { Enabled bool `json:"enabled"` Address string `json:"address"` CertFile string `json:"cert_file,omitempty"` KeyFile string `json:"key_file,omitempty"` ShutdownGracePeriod fxp.Int `json:"shutdown_grace_period"` ReadTimeout fxp.Int `json:"read_timeout"` WriteTimeout fxp.Int `json:"write_timeout"` IdleTimeout fxp.Int `json:"idle_timeout"` }
Server holds the settings for the embedded web server.
type Session ¶
type Session struct { ID tid.TID `json:"id"` UserKey string `json:"user"` Issued time.Time `json:"issued"` LastUsed time.Time `json:"last_used"` }
Session holds a session's information.
type Settings ¶
type Settings struct { Server // contains filtered or unexported fields }
Settings holds the settings for the embedded web server.
func NewSettingsFromFile ¶
NewSettingsFromFile loads new settings from a file.
func (*Settings) AccessList ¶
AccessList returns the access list for a user.
func (*Settings) CopyFrom ¶
CopyFrom copies the settings from the other Settings to this Settings object. If 'other' is nil, the default settings are used.
func (*Settings) CreateSession ¶
CreateSession creates a session.
func (*Settings) CreateUser ¶
CreateUser creates a user. Returns true on success, false if a user by that name already exists.
func (*Settings) LookupSession ¶
LookupSession looks up a session, updating its last used time and returning the user's name if found.
func (*Settings) LookupUserNameAndPassword ¶
func (s *Settings) LookupUserNameAndPassword(name string) (actualName, hashedPassword string, ok bool)
LookupUserNameAndPassword looks up a user.
func (*Settings) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*Settings) PruneSessions ¶
func (s *Settings) PruneSessions()
PruneSessions removes expired sessions.
func (*Settings) RemoveSession ¶
RemoveSession removes a session.
func (*Settings) RenameUser ¶
RenameUser renames a user. Returns true on success, false if the new name already exists or the user can't be found.
func (*Settings) SetAccessList ¶
SetAccessList sets the access list for a user.
func (*Settings) SetUserPassword ¶
SetUserPassword sets the user's password. Returns true on success, false if the user can't be found.
func (*Settings) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type User ¶
type User struct { Name string `json:"name"` HashedPassword string `json:"hash"` AccessList map[string]Access `json:"access_list"` // Key is the name the user sees and uses for the directory. }
User holds information for a web user.
func (*User) AccessListWithKeys ¶
func (u *User) AccessListWithKeys() []*AccessWithKey
AccessListWithKeys returns the access list with keys.