Documentation ¶
Index ¶
- Constants
- func AddMember(ls []LDAPConfiguration, group *LDAPGroup, user *LDAPUser, ...) error
- func AddOwner(ls []LDAPConfiguration, group *LDAPGroup, user *LDAPUser, ...) error
- func AllowedOriginMethod(opts *CORSOptions, origin, method string) bool
- func AuthHandlersRegister(router *mux.Router, c Settings)
- func Authenticate(ls []LDAPConfiguration, user, pass string) (bool, error)
- func CreateGroup(ls []LDAPConfiguration, group *LDAPGroup, creds *LDAPCredentials) error
- func CreateUser(ls []LDAPConfiguration, user *LDAPUser, password string, ...) error
- func DisableUser(ls []LDAPConfiguration, user *LDAPUser, creds *LDAPCredentials, reason string) error
- func EditGroup(ls []LDAPConfiguration, group *LDAPGroup, creds *LDAPCredentials) error
- func EditUser(ls []LDAPConfiguration, user *LDAPUser, creds *LDAPCredentials) error
- func EnableUser(ls []LDAPConfiguration, user *LDAPUser, creds *LDAPCredentials) error
- func IsMember(ls []LDAPConfiguration, groupname, username string) (bool, error)
- func ListenForReload(c Settings, dir string)
- func LoadTemplates(directory string) (map[string]*template.Template, error)
- func Migrate(connection, path string) error
- func NotAuth(token *jwt.Token) bool
- func RemoveMember(ls []LDAPConfiguration, group *LDAPGroup, user *LDAPUser, ...) error
- func RemoveOwner(ls []LDAPConfiguration, group *LDAPGroup, user *LDAPUser, ...) error
- func SetForgotPassword(ls []LDAPConfiguration, user *LDAPUser, newPass string) error
- func SetPassword(ls []LDAPConfiguration, user *LDAPUser, oldPass, newPass string) error
- func SetupJWTMiddleware(private, public string) (*jwtmiddleware.JWTMiddleware, *rsa.PrivateKey, string, error)
- func SynchronizeAll(ls []LDAPConfiguration, r SyncReceiver, c chan error)
- func TemplatesRegister(router *mux.Router, c Settings)
- func UsernameFromToken(token *jwt.Token) string
- type AppError
- func LoginHandler(w http.ResponseWriter, r *http.Request) *AppError
- func LogoutHandler(w http.ResponseWriter, r *http.Request) *AppError
- func ParseJSON(data interface{}, query string) *AppError
- func ReceiveJSON(data interface{}, r *http.Request) *AppError
- func RefreshHandler(w http.ResponseWriter, r *http.Request) *AppError
- func SendJSON(data interface{}, w http.ResponseWriter, r *http.Request) *AppError
- func TemplateHandler(w http.ResponseWriter, r *http.Request, template string) *AppError
- type AppHandler
- type CORSOptions
- type ErrorInfo
- type Events
- type LDAP
- func (l LDAP) AddMember(group *LDAPGroup, user *LDAPUser, creds *LDAPCredentials) error
- func (l LDAP) AddOwner(group *LDAPGroup, user *LDAPUser, creds *LDAPCredentials) error
- func (l LDAP) Auth(user, pass string) (bool, error)
- func (l LDAP) CreateGroup(group *LDAPGroup, creds *LDAPCredentials) error
- func (l LDAP) CreateUser(user *LDAPUser, password string, creds *LDAPCredentials) error
- func (l LDAP) DNToGroupname(dn string) string
- func (l LDAP) DNToUsername(dn string) string
- func (l LDAP) DisableUser(user *LDAPUser, creds *LDAPCredentials, reason string) error
- func (l LDAP) EditGroup(group *LDAPGroup, creds *LDAPCredentials) error
- func (l LDAP) EditUser(user *LDAPUser, creds *LDAPCredentials) error
- func (l LDAP) EnableUser(user *LDAPUser, creds *LDAPCredentials) error
- func (l LDAP) FormatServer() string
- func (l LDAP) GetAdminGroup() string
- func (l LDAP) GetBaseDN() string
- func (l LDAP) GetBindPassword() string
- func (l LDAP) GetBindUsername() string
- func (l LDAP) GetForgotPassword() string
- func (l LDAP) GetForgotUsername() string
- func (l LDAP) GetGroup(groupname string) (*LDAPGroup, error)
- func (l LDAP) GetGroupDN() string
- func (l LDAP) GetHost() string
- func (l LDAP) GetPort() uint
- func (l LDAP) GetUser(username string) (*LDAPUser, error)
- func (l LDAP) GetUserDN() string
- func (l LDAP) GroupnameToDN(groupname string) string
- func (l LDAP) IsMember(groupname, username string) (bool, error)
- func (l LDAP) RemoveMember(group *LDAPGroup, user *LDAPUser, creds *LDAPCredentials) error
- func (l LDAP) RemoveOwner(group *LDAPGroup, user *LDAPUser, creds *LDAPCredentials) error
- func (l LDAP) SetForgotPassword(user *LDAPUser, newPass string) error
- func (l LDAP) SetPassword(user *LDAPUser, oldPass, newPass string) error
- func (l LDAP) Setup(bind bool) (*ldap.Conn, error)
- func (l LDAP) SynchronizeAll(r SyncReceiver) error
- func (l LDAP) UsernameToDN(username string) string
- type LDAPConfiguration
- type LDAPCredentials
- type LDAPGroup
- type LDAPUser
- type MockSettings
- func (s MockSettings) GetCORSOptions() *CORSOptions
- func (s MockSettings) GetEvents() Events
- func (s MockSettings) GetJWT() *jwtmiddleware.JWTMiddleware
- func (s MockSettings) GetJWTPublicKey() string
- func (s MockSettings) GetJWTSigningKey() *rsa.PrivateKey
- func (s MockSettings) GetLDAP() []LDAPConfiguration
- func (s MockSettings) GetPool() *bpool.BufferPool
- func (s MockSettings) GetTemplates() map[string]*template.Template
- func (s MockSettings) SetTemplates(map[string]*template.Template)
- type QuerySettings
- type Settings
- type SyncReceiver
- type User
Constants ¶
const ( ASC = "ascend" DESC = "descend" )
const (
ADMIN_LOCKED_TIME = "000001010000Z"
)
Variables ¶
This section is empty.
Functions ¶
func AddMember ¶
func AddMember(ls []LDAPConfiguration, group *LDAPGroup, user *LDAPUser, creds *LDAPCredentials) error
func AddOwner ¶
func AddOwner(ls []LDAPConfiguration, group *LDAPGroup, user *LDAPUser, creds *LDAPCredentials) error
func AllowedOriginMethod ¶
func AllowedOriginMethod(opts *CORSOptions, origin, method string) bool
func AuthHandlersRegister ¶
func Authenticate ¶
func Authenticate(ls []LDAPConfiguration, user, pass string) (bool, error)
func CreateGroup ¶
func CreateGroup(ls []LDAPConfiguration, group *LDAPGroup, creds *LDAPCredentials) error
func CreateUser ¶
func CreateUser(ls []LDAPConfiguration, user *LDAPUser, password string, creds *LDAPCredentials) error
func DisableUser ¶
func DisableUser(ls []LDAPConfiguration, user *LDAPUser, creds *LDAPCredentials, reason string) error
func EditGroup ¶
func EditGroup(ls []LDAPConfiguration, group *LDAPGroup, creds *LDAPCredentials) error
func EditUser ¶
func EditUser(ls []LDAPConfiguration, user *LDAPUser, creds *LDAPCredentials) error
func EnableUser ¶
func EnableUser(ls []LDAPConfiguration, user *LDAPUser, creds *LDAPCredentials) error
func ListenForReload ¶
func RemoveMember ¶
func RemoveMember(ls []LDAPConfiguration, group *LDAPGroup, user *LDAPUser, creds *LDAPCredentials) error
func RemoveOwner ¶
func RemoveOwner(ls []LDAPConfiguration, group *LDAPGroup, user *LDAPUser, creds *LDAPCredentials) error
func SetForgotPassword ¶
func SetForgotPassword(ls []LDAPConfiguration, user *LDAPUser, newPass string) error
func SetPassword ¶
func SetPassword(ls []LDAPConfiguration, user *LDAPUser, oldPass, newPass string) error
func SetupJWTMiddleware ¶
func SetupJWTMiddleware(private, public string) (*jwtmiddleware.JWTMiddleware, *rsa.PrivateKey, string, error)
func SynchronizeAll ¶
func SynchronizeAll(ls []LDAPConfiguration, r SyncReceiver, c chan error)
func TemplatesRegister ¶
func UsernameFromToken ¶
Types ¶
type AppError ¶
Code is HTTP status code, Error the Go error describing the problem, possibly for re-display to the user.
func LoginHandler ¶
func LoginHandler(w http.ResponseWriter, r *http.Request) *AppError
Takes login info and returns a JWT if successful, 403 if not
func LogoutHandler ¶
func LogoutHandler(w http.ResponseWriter, r *http.Request) *AppError
Does nothing for now
func ReceiveJSON ¶
func RefreshHandler ¶
func RefreshHandler(w http.ResponseWriter, r *http.Request) *AppError
Takes an existing, valid token and issues a newer, fresher expiration for it.
func TemplateHandler ¶
type AppHandler ¶
type AppHandler func(http.ResponseWriter, *http.Request) *AppError
func Auth ¶
func Auth(fn AppHandler) AppHandler
Middleware to mark a resource as one requiring authentication to access
func CORS ¶
func CORS(fn AppHandler) AppHandler
func Middleware ¶
func Middleware(fn AppHandler, c interface{}) AppHandler
Always conclude by wrapping handlers in Middleware. If there are exceptions to this rule, it should be because no level requires context. All other wrappers depend on it; for instance, AuthRequired needs the context to determine logged-in status.
func PartialAuth ¶
func PartialAuth(fn AppHandler) AppHandler
Middleware to mark a resource as granting greater access when authenticated, but authentication not required for limited access.
func TemplateMiddleware ¶
func TemplateMiddleware(tmpl string) AppHandler
func (AppHandler) ServeHTTP ¶
func (fn AppHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type CORSOptions ¶
type CORSOptions struct {
Origins []string `json:"origins"`
}
type LDAP ¶
type LDAP struct { Host string Port uint BindUsername string BindPassword string ForgotUsername string ForgotPassword string AdminGroup string BaseDN string UserDN string GroupDN string }
func (LDAP) AddMember ¶
func (l LDAP) AddMember(group *LDAPGroup, user *LDAPUser, creds *LDAPCredentials) error
func (LDAP) AddOwner ¶
func (l LDAP) AddOwner(group *LDAPGroup, user *LDAPUser, creds *LDAPCredentials) error
func (LDAP) CreateGroup ¶
func (l LDAP) CreateGroup(group *LDAPGroup, creds *LDAPCredentials) error
func (LDAP) CreateUser ¶
func (l LDAP) CreateUser(user *LDAPUser, password string, creds *LDAPCredentials) error
func (LDAP) DNToGroupname ¶
func (LDAP) DNToUsername ¶
func (LDAP) DisableUser ¶
func (l LDAP) DisableUser(user *LDAPUser, creds *LDAPCredentials, reason string) error
func (LDAP) EnableUser ¶
func (l LDAP) EnableUser(user *LDAPUser, creds *LDAPCredentials) error
func (LDAP) FormatServer ¶
func (LDAP) GetAdminGroup ¶
func (LDAP) GetBindPassword ¶
func (LDAP) GetBindUsername ¶
func (LDAP) GetForgotPassword ¶
func (LDAP) GetForgotUsername ¶
func (LDAP) GetGroupDN ¶
func (LDAP) GroupnameToDN ¶
func (LDAP) RemoveMember ¶
func (l LDAP) RemoveMember(group *LDAPGroup, user *LDAPUser, creds *LDAPCredentials) error
func (LDAP) RemoveOwner ¶
func (l LDAP) RemoveOwner(group *LDAPGroup, user *LDAPUser, creds *LDAPCredentials) error
func (LDAP) SetForgotPassword ¶
func (LDAP) SynchronizeAll ¶
func (l LDAP) SynchronizeAll(r SyncReceiver) error
func (LDAP) UsernameToDN ¶
type LDAPConfiguration ¶
type LDAPConfiguration interface { GetHost() string GetPort() uint GetBindUsername() string GetBindPassword() string GetForgotUsername() string GetForgotPassword() string GetAdminGroup() string GetBaseDN() string GetUserDN() string GetGroupDN() string UsernameToDN(string) string GroupnameToDN(string) string DNToUsername(string) string DNToGroupname(string) string FormatServer() string Auth(string, string) (bool, error) GetUser(string) (*LDAPUser, error) GetGroup(string) (*LDAPGroup, error) CreateUser(*LDAPUser, string, *LDAPCredentials) error EditUser(*LDAPUser, *LDAPCredentials) error EnableUser(*LDAPUser, *LDAPCredentials) error DisableUser(*LDAPUser, *LDAPCredentials, string) error IsMember(string, string) (bool, error) CreateGroup(*LDAPGroup, *LDAPCredentials) error EditGroup(*LDAPGroup, *LDAPCredentials) error AddMember(*LDAPGroup, *LDAPUser, *LDAPCredentials) error RemoveMember(*LDAPGroup, *LDAPUser, *LDAPCredentials) error AddOwner(*LDAPGroup, *LDAPUser, *LDAPCredentials) error RemoveOwner(*LDAPGroup, *LDAPUser, *LDAPCredentials) error SetPassword(*LDAPUser, string, string) error SetForgotPassword(*LDAPUser, string) error SynchronizeAll(SyncReceiver) error }
type LDAPCredentials ¶
type LDAPUser ¶
type MockSettings ¶
type MockSettings struct { }
func (MockSettings) GetCORSOptions ¶
func (s MockSettings) GetCORSOptions() *CORSOptions
func (MockSettings) GetEvents ¶
func (s MockSettings) GetEvents() Events
func (MockSettings) GetJWT ¶
func (s MockSettings) GetJWT() *jwtmiddleware.JWTMiddleware
func (MockSettings) GetJWTPublicKey ¶
func (s MockSettings) GetJWTPublicKey() string
func (MockSettings) GetJWTSigningKey ¶
func (s MockSettings) GetJWTSigningKey() *rsa.PrivateKey
func (MockSettings) GetLDAP ¶
func (s MockSettings) GetLDAP() []LDAPConfiguration
func (MockSettings) GetPool ¶
func (s MockSettings) GetPool() *bpool.BufferPool
func (MockSettings) GetTemplates ¶
func (s MockSettings) GetTemplates() map[string]*template.Template
func (MockSettings) SetTemplates ¶
func (s MockSettings) SetTemplates(map[string]*template.Template)
type QuerySettings ¶
func QuerySetHelper ¶
func QuerySetHelper(args url.Values, col, ord string) (*QuerySettings, error)
Supports ordering and subsetting of queries by building the relevant portions of a SELECT query out of URL query args. Returns a string with the relevant clauses, generally suitable for appending to the end of a query (without said clauses).
- start: integer, starting index of query. Defaults to 0.
- count: integer, max size of query. Defaults to 0, which is unlimited. This will probably change!
- field: string, name of column to sort by. Default supplied as col arg to function. Leave arg empty to ignore sorting.
- order: ("ascend"|"descend") Default supplied as ord arg to function.
type Settings ¶
type Settings interface { GetLDAP() []LDAPConfiguration SetTemplates(map[string]*template.Template) GetTemplates() map[string]*template.Template GetPool() *bpool.BufferPool GetJWT() *jwtmiddleware.JWTMiddleware GetJWTSigningKey() *rsa.PrivateKey GetJWTPublicKey() string GetEvents() Events GetCORSOptions() *CORSOptions }