Documentation
¶
Index ¶
- Constants
- Variables
- func GetSessionToken(r *http.Request) string
- func RequireSameOrigin(allowedOrigin string) func(http.Handler) http.Handler
- func VerifyRequestOrigin(r *http.Request, allowedOrigin string) bool
- type Client
- func (c *Client) ClearSessionCookie(w http.ResponseWriter)
- func (c *Client) CreateSession(ctx context.Context, userID string) (string, error)
- func (c *Client) CreateSessionWithAuthLevel(ctx context.Context, userID string, authLevel int) (string, error)
- func (c *Client) DeleteSession(ctx context.Context, sessionID string) error
- func (c *Client) DeleteUserSessions(ctx context.Context, userID string) error
- func (c *Client) Logout(ctx context.Context) (string, error)
- func (c *Client) LogoutHTTP(w http.ResponseWriter, r *http.Request) error
- func (c *Client) RequireFullSession(next http.Handler) http.Handler
- func (c *Client) RequireSession(next http.Handler) http.Handler
- func (c *Client) SessionMiddleware() func(http.Handler) http.Handler
- func (c *Client) SetSessionCookie(w http.ResponseWriter, token string)
- func (c *Client) UpgradeSessionToFull(ctx context.Context, sessionID string) error
- func (c *Client) ValidateSession(ctx context.Context, token string) (*Session, *User, error)
- type ClientConfig
- type Session
- type User
Constants ¶
View Source
const ( SessionAuthLevelPrimary = 1 SessionAuthLevelFull = 2 )
View Source
const SessionCookieName = "session"
Variables ¶
View Source
var ErrInvalidSession = errors.New("invalid session")
Functions ¶
func GetSessionToken ¶
func RequireSameOrigin ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(cfg ClientConfig) (*Client, error)
func (*Client) ClearSessionCookie ¶
func (c *Client) ClearSessionCookie(w http.ResponseWriter)
func (*Client) CreateSession ¶
func (*Client) CreateSessionWithAuthLevel ¶
func (*Client) DeleteSession ¶
func (*Client) DeleteUserSessions ¶
func (*Client) LogoutHTTP ¶
func (*Client) RequireFullSession ¶
func (*Client) SessionMiddleware ¶
func (*Client) SetSessionCookie ¶
func (c *Client) SetSessionCookie(w http.ResponseWriter, token string)
func (*Client) UpgradeSessionToFull ¶
type ClientConfig ¶
Click to show internal directories.
Click to hide internal directories.