Documentation ¶
Index ¶
- Constants
- Variables
- func Asset(name string) ([]byte, error)
- func AssetDir(name string) ([]string, error)
- func AssetInfo(name string) (os.FileInfo, error)
- func AssetNames() []string
- func LayoutTemplateCopy() *template.Template
- func MustAsset(name string) []byte
- func NewWebLoginModule(t marvin.Team) marvin.Module
- func RestoreAsset(dir, name string) error
- func RestoreAssets(dir, name string) error
- type API
- type ActionSourceWeb
- type LayoutContent
- func (w *LayoutContent) DCurrentUser() User
- func (w *LayoutContent) NavbarItems() interface{}
- func (w *LayoutContent) SlackUser() (*slack.User, error)
- func (w *LayoutContent) StartIntraURL(extraScopes ...string) string
- func (w *LayoutContent) StartSlackURL(extraScopes ...string) string
- func (w *LayoutContent) Team() marvin.Team
- type User
- func (u *User) Destroy() error
- func (u *User) HasScopeSlack(scope string) bool
- func (u *User) Login(w http.ResponseWriter, r *http.Request) error
- func (u *User) Logout(w http.ResponseWriter, r *http.Request) error
- func (u User) NameWarning() bool
- func (u *User) UpdateIntra(login string, token *oauth2.Token, scopes []string) error
- func (u *User) UpdateSlack(uid slack.UserID, name, token string, scopes []string) error
- type WebLoginModule
- func (mod *WebLoginModule) CommandWebAuthenticate(t marvin.Team, args *marvin.CommandArguments) marvin.CommandResult
- func (mod *WebLoginModule) DestroySession(w http.ResponseWriter, r *http.Request)
- func (mod *WebLoginModule) Disable(team marvin.Team)
- func (mod *WebLoginModule) Enable(team marvin.Team)
- func (mod *WebLoginModule) GetCurrentUser(w http.ResponseWriter, r *http.Request) (*User, error)
- func (mod *WebLoginModule) GetOrNewCurrentUser(w http.ResponseWriter, r *http.Request) (*User, error)
- func (mod *WebLoginModule) GetUserByID(uid int64) (*User, error)
- func (mod *WebLoginModule) GetUserByIntra(login string) (*User, error)
- func (mod *WebLoginModule) GetUserBySlack(slackID slack.UserID) (*User, error)
- func (mod *WebLoginModule) HTTPError(w http.ResponseWriter, r *http.Request, err error)
- func (mod *WebLoginModule) Identifier() marvin.ModuleID
- func (mod *WebLoginModule) Load(t marvin.Team)
- func (mod *WebLoginModule) OAuthAltSlackStart(w http.ResponseWriter, r *http.Request)
- func (mod *WebLoginModule) OAuthIntraCallback(w http.ResponseWriter, r *http.Request)
- func (mod *WebLoginModule) OAuthIntraStart(w http.ResponseWriter, r *http.Request)
- func (mod *WebLoginModule) OAuthSlackCallback(w http.ResponseWriter, r *http.Request)
- func (mod *WebLoginModule) OAuthSlackStart(w http.ResponseWriter, r *http.Request)
- func (mod *WebLoginModule) Serve404(w http.ResponseWriter, r *http.Request)
- func (mod *WebLoginModule) ServeAsset(w http.ResponseWriter, r *http.Request)
- func (mod *WebLoginModule) ServeCSRF(w http.ResponseWriter, r *http.Request)
- func (mod *WebLoginModule) ServeRoot(w http.ResponseWriter, r *http.Request)
- func (mod *WebLoginModule) StartIntraURL(returnURL string, extraScopes ...string) string
- func (mod *WebLoginModule) StartSlackURL(returnURL string, extraScopes ...string) string
- func (mod *WebLoginModule) StartURL() string
Constants ¶
const ()
const Identifier = "weblogin"
Variables ¶
var (
ErrBadCookie = errors.New("Bad cookie data")
)
var ErrNoSuchUser = errors.New("That user does not exist.")
var ErrNotLoggedIn = errors.New("You are not logged in.")
string URL string }{ {Name: NavSectionFactoids, URL: "/factoids"}, {Name: NavSectionInvite, URL: "/invites"}, {Name: NavSectionLogs, URL: "/logs"}, }Name
Functions ¶
func Asset ¶
Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.
func AssetDir ¶
AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:
data/ foo.txt img/ a.png b.png
then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.
func AssetInfo ¶
AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.
func LayoutTemplateCopy ¶
func MustAsset ¶
MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.
func RestoreAsset ¶
RestoreAsset restores an asset under the given directory
func RestoreAssets ¶
RestoreAssets restores an asset under the given directory recursively
Types ¶
type API ¶
type API interface { marvin.Module // GetCurrentUser gets the current User object for the request's cookies. // If there is no logged in user, this method returns (nil, nil). // An error is returned only in case of corrupt cookie data. GetCurrentUser(w http.ResponseWriter, r *http.Request) (*User, error) // GetUserBySlack gets the User object for the given Slack user. // If no associated Slack account is found, ErrNoSuchUser is returned. GetUserBySlack(slackID slack.UserID) (*User, error) // GetUserByIntra gets the User object for the given Intra username. // If no associated Intra account is found, ErrNoSuchUser is returned. GetUserByIntra(login string) (*User, error) // StartSlackURL returns the URL to redirect to to start Slack authentication. StartSlackURL(returnURL string, extraScopes ...string) string // StartSlackURL returns the URL to redirect to to start Intra authentication. StartIntraURL(returnURL string, extraScopes ...string) string // HTTPError renders a formatted error page. HTTPError(w http.ResponseWriter, r *http.Request, err error) }
type ActionSourceWeb ¶
func (ActionSourceWeb) AccessLevel ¶
func (ws ActionSourceWeb) AccessLevel() marvin.AccessLevel
func (ActionSourceWeb) ArchiveLink ¶
func (ws ActionSourceWeb) ArchiveLink() string
func (ActionSourceWeb) ChannelID ¶
func (ws ActionSourceWeb) ChannelID() slack.ChannelID
func (ActionSourceWeb) MsgTimestamp ¶
func (ws ActionSourceWeb) MsgTimestamp() slack.MessageTS
func (ActionSourceWeb) UserID ¶
func (ws ActionSourceWeb) UserID() slack.UserID
type LayoutContent ¶
type LayoutContent struct { WLMod *WebLoginModule Title string CurrentURL string CurrentUser *User BodyData interface{} // contains filtered or unexported fields }
func NewLayoutContent ¶
func NewLayoutContent(team marvin.Team, w http.ResponseWriter, r *http.Request, navSection string) (*LayoutContent, error)
NewLayoutContent will always succeed, but may leave some fields unfilled when err != nil.
func (*LayoutContent) DCurrentUser ¶
func (w *LayoutContent) DCurrentUser() User
func (*LayoutContent) NavbarItems ¶
func (w *LayoutContent) NavbarItems() interface{}
func (*LayoutContent) StartIntraURL ¶
func (w *LayoutContent) StartIntraURL(extraScopes ...string) string
func (*LayoutContent) StartSlackURL ¶
func (w *LayoutContent) StartSlackURL(extraScopes ...string) string
func (*LayoutContent) Team ¶
func (w *LayoutContent) Team() marvin.Team
type User ¶
type User struct { ID int64 SlackUser slack.UserID SlackName string SlackToken string SlackScopes []string IntraLogin string IntraToken *oauth2.Token IntraScopes []string // contains filtered or unexported fields }
A User contains possibly a logged-in Slack user, and possibly a logged-in Intra user.
func (*User) HasScopeSlack ¶
func (*User) Login ¶
Login writes an auth cookie. This cannot be used with a User object not yet saved to the database (ID == -1).
func (*User) Logout ¶
Logout deletes the auth cookie. Cannot be used with a User object not saved to the database.
func (User) NameWarning ¶
func (*User) UpdateIntra ¶
UpdateIntra saves the given intra token to the database, and creates a new row in the database if necessary (id == -1).
type WebLoginModule ¶
type WebLoginModule struct { IntraOAuthConfig oauth2.Config // contains filtered or unexported fields }
func (*WebLoginModule) CommandWebAuthenticate ¶
func (mod *WebLoginModule) CommandWebAuthenticate(t marvin.Team, args *marvin.CommandArguments) marvin.CommandResult
func (*WebLoginModule) DestroySession ¶
func (mod *WebLoginModule) DestroySession(w http.ResponseWriter, r *http.Request)
func (*WebLoginModule) Disable ¶
func (mod *WebLoginModule) Disable(team marvin.Team)
func (*WebLoginModule) Enable ¶
func (mod *WebLoginModule) Enable(team marvin.Team)
func (*WebLoginModule) GetCurrentUser ¶
func (mod *WebLoginModule) GetCurrentUser(w http.ResponseWriter, r *http.Request) (*User, error)
GetCurrentUser looks up the current user based on the request. If there is no currently logged in user, it returns a nil *User instead of an error.
func (*WebLoginModule) GetOrNewCurrentUser ¶
func (mod *WebLoginModule) GetOrNewCurrentUser(w http.ResponseWriter, r *http.Request) (*User, error)
GetOrNewCurrentUser looks up the current user based on the request. If there is no currently logged in user, it returns a new User object with a pseudo-id of -1.
func (*WebLoginModule) GetUserByID ¶
func (mod *WebLoginModule) GetUserByID(uid int64) (*User, error)
func (*WebLoginModule) GetUserByIntra ¶
func (mod *WebLoginModule) GetUserByIntra(login string) (*User, error)
GetUserByIntra checks for an existing user with the given Intra login name.
func (*WebLoginModule) GetUserBySlack ¶
func (mod *WebLoginModule) GetUserBySlack(slackID slack.UserID) (*User, error)
GetUserBySlack checks for an existing user with the given Slack user ID.
func (*WebLoginModule) HTTPError ¶
func (mod *WebLoginModule) HTTPError(w http.ResponseWriter, r *http.Request, err error)
func (*WebLoginModule) Identifier ¶
func (mod *WebLoginModule) Identifier() marvin.ModuleID
func (*WebLoginModule) Load ¶
func (mod *WebLoginModule) Load(t marvin.Team)
func (*WebLoginModule) OAuthAltSlackStart ¶
func (mod *WebLoginModule) OAuthAltSlackStart(w http.ResponseWriter, r *http.Request)
func (*WebLoginModule) OAuthIntraCallback ¶
func (mod *WebLoginModule) OAuthIntraCallback(w http.ResponseWriter, r *http.Request)
func (*WebLoginModule) OAuthIntraStart ¶
func (mod *WebLoginModule) OAuthIntraStart(w http.ResponseWriter, r *http.Request)
func (*WebLoginModule) OAuthSlackCallback ¶
func (mod *WebLoginModule) OAuthSlackCallback(w http.ResponseWriter, r *http.Request)
func (*WebLoginModule) OAuthSlackStart ¶
func (mod *WebLoginModule) OAuthSlackStart(w http.ResponseWriter, r *http.Request)
func (*WebLoginModule) Serve404 ¶
func (mod *WebLoginModule) Serve404(w http.ResponseWriter, r *http.Request)
func (*WebLoginModule) ServeAsset ¶
func (mod *WebLoginModule) ServeAsset(w http.ResponseWriter, r *http.Request)
func (*WebLoginModule) ServeCSRF ¶
func (mod *WebLoginModule) ServeCSRF(w http.ResponseWriter, r *http.Request)
func (*WebLoginModule) ServeRoot ¶
func (mod *WebLoginModule) ServeRoot(w http.ResponseWriter, r *http.Request)
func (*WebLoginModule) StartIntraURL ¶
func (mod *WebLoginModule) StartIntraURL(returnURL string, extraScopes ...string) string
func (*WebLoginModule) StartSlackURL ¶
func (mod *WebLoginModule) StartSlackURL(returnURL string, extraScopes ...string) string
func (*WebLoginModule) StartURL ¶
func (mod *WebLoginModule) StartURL() string