Documentation ¶
Index ¶
- Constants
- Variables
- func MustLogin(c *Config, s SessionStorage) func(http.Handler) http.Handler
- func MustNotLogin(c *Config, s SessionStorage) func(http.Handler) http.Handler
- func NewAuthorizationMiddleware(ctx context.Context, c *Config, out io.Writer) (http.Handler, func(http.Handler) http.Handler)
- func NewIdentityAwareProxyHandler(c *Config, s SessionStorage, u *IdentityRegister) (http.Handler, error)
- func NewReverseProxy(config *Config, s SessionStorage) (http.Handler, error)
- func SplitBlobPath(resourceUrl string) (string, string, error)
- type AllUserSessions
- type ClientSessionFieldType
- type Config
- type Directive
- type FederatedAccount
- type GitHubConfig
- type IDPlatform
- type IdentityRegister
- func NewIdentityRegister(ctx context.Context, c *Config, out io.Writer) (*IdentityRegister, []string, error)
- func NewIdentityRegisterFromConfig(ctx context.Context, c *Config, out io.Writer) (*IdentityRegister, []string, error)
- func NewIdentityRegisterFromEnv(ctx context.Context, envs []string, out io.Writer) (*IdentityRegister, []string, error)
- type OIDCConfig
- type ProxyTransport
- type RedisConfig
- type RedisSessionStorage
- func (s RedisSessionStorage) AddLoginInfo(ctx context.Context, oldSessionID string, info map[string]string) (newSessionID string, err error)
- func (s RedisSessionStorage) FindBySessionToken(ctx context.Context, token string) (*Session, error)
- func (s RedisSessionStorage) GetUserSessions(ctx context.Context, userID string) ([]SingleSessionData, error)
- func (s RedisSessionStorage) Logout(ctx context.Context, sessionID string) error
- func (s RedisSessionStorage) RenewSession(ctx context.Context, oldSessionID string) (sessionID string, err error)
- func (s RedisSessionStorage) StartLogin(ctx context.Context, info map[string]string) (sessionID string, err error)
- func (s RedisSessionStorage) StartSession(ctx context.Context, oldSessionID string, user *User, r *http.Request, ...) (sessionID string, info map[string]string, err error)
- func (s RedisSessionStorage) UpdateSessionData(ctx context.Context, sessionID string, directives []*Directive) (err error)
- type Route
- type ServerlessSessionStorage
- func (s ServerlessSessionStorage) AddLoginInfo(ctx context.Context, oldSessionID string, info map[string]string) (newSessionID string, err error)
- func (s *ServerlessSessionStorage) Close()
- func (s *ServerlessSessionStorage) FindBySessionToken(ctx context.Context, token string) (*Session, error)
- func (s *ServerlessSessionStorage) GetUserSessions(ctx context.Context, userID string) ([]SingleSessionData, error)
- func (s ServerlessSessionStorage) Logout(ctx context.Context, sessionID string) error
- func (s ServerlessSessionStorage) RenewSession(ctx context.Context, oldSessionID string) (newSessionID string, err error)
- func (s ServerlessSessionStorage) StartLogin(ctx context.Context, info map[string]string) (sessionID string, err error)
- func (s *ServerlessSessionStorage) StartSession(ctx context.Context, oldSessionID string, user *User, r *http.Request, ...) (sessionID string, info map[string]string, err error)
- func (s ServerlessSessionStorage) UpdateSessionData(ctx context.Context, sessionID string, directives []*Directive) (err error)
- type Session
- type SessionStatus
- type SessionStorage
- type SingleSessionData
- func (s SingleSessionData) Browser() string
- func (s SingleSessionData) IdP() string
- func (s SingleSessionData) LastAccessAtForHuman() string
- func (s SingleSessionData) LastAccessAtFormat() string
- func (s SingleSessionData) Location() string
- func (s SingleSessionData) LoginAtForHuman() string
- func (s SingleSessionData) LoginAtFormat() string
- func (s SingleSessionData) OS() string
- type TwitterConfig
- type UnixTime
- type User
- type UserSession
Constants ¶
View Source
const ( LoginPageTemplate = "login.html" DebugLoginPageTemplate = "debug_login.html" UserStatusPageTemplate = "user_status.html" UserSessionsPageTemplate = "user_sessions.html" )
Variables ¶
View Source
var ( ErrUserNotFound = errors.New("user not found") ErrNotModified = errors.New("not modified") )
View Source
var ErrInvalidSessionToken = errors.New("invalid session token")
Functions ¶
func MustNotLogin ¶
func NewIdentityAwareProxyHandler ¶
func NewIdentityAwareProxyHandler(c *Config, s SessionStorage, u *IdentityRegister) (http.Handler, error)
func NewReverseProxy ¶
func NewReverseProxy(config *Config, s SessionStorage) (http.Handler, error)
Types ¶
type AllUserSessions ¶
type AllUserSessions []SingleSessionData
func (AllUserSessions) WriteAsJson ¶
func (as AllUserSessions) WriteAsJson(w io.Writer) error
type ClientSessionFieldType ¶
type ClientSessionFieldType int
const ( CookieField ClientSessionFieldType = iota + 1 CookieWithJSField InvalidField )
type Config ¶
type Config struct { Port uint16 Host string DevMode bool AdminPort uint16 TlsCert string TlsKey string ForwardTo []Route DefaultLandingPage string UserTable string UserTableReloadTerm time.Duration SessionStorage string ServerSessionField string ClientSessionFieldCookie ClientSessionFieldType ClientSessionKey string LoginTimeoutTerm time.Duration SessionIdleTimeoutTerm time.Duration SessionAbsoluteTimeoutTerm time.Duration HTMLTemplateFolder string Twitter TwitterConfig GitHub GitHubConfig OIDC OIDCConfig RedisSession RedisConfig GeoIPDatabasePath string Users []*User // contains filtered or unexported fields }
type FederatedAccount ¶
type FederatedAccount struct { Service IDPlatform `json:"service"` Account string `json:"account"` }
type GitHubConfig ¶
func (GitHubConfig) Available ¶
func (c GitHubConfig) Available() bool
type IDPlatform ¶
type IDPlatform string
const ( Twitter IDPlatform = "Twitter" GitHub IDPlatform = "GitHub" OIDC IDPlatform = "OIDC" )
type IdentityRegister ¶
type IdentityRegister struct {
// contains filtered or unexported fields
}
func NewIdentityRegister ¶
func (IdentityRegister) AllUsers ¶
func (ir IdentityRegister) AllUsers() []*User
func (*IdentityRegister) FindUserByID ¶
func (ir *IdentityRegister) FindUserByID(userID string) (*User, error)
func (*IdentityRegister) FindUserOf ¶
func (ir *IdentityRegister) FindUserOf(idp IDPlatform, userID string) (*User, error)
type OIDCConfig ¶
func (OIDCConfig) Available ¶
func (c OIDCConfig) Available() bool
type ProxyTransport ¶
type ProxyTransport struct {
// contains filtered or unexported fields
}
type RedisConfig ¶
type RedisConfig struct {
Host string
}
type RedisSessionStorage ¶
type RedisSessionStorage struct { }
func (RedisSessionStorage) AddLoginInfo ¶
func (RedisSessionStorage) FindBySessionToken ¶
func (RedisSessionStorage) GetUserSessions ¶
func (s RedisSessionStorage) GetUserSessions(ctx context.Context, userID string) ([]SingleSessionData, error)
func (RedisSessionStorage) Logout ¶
func (s RedisSessionStorage) Logout(ctx context.Context, sessionID string) error
func (RedisSessionStorage) RenewSession ¶
func (RedisSessionStorage) StartLogin ¶
func (RedisSessionStorage) StartSession ¶
func (RedisSessionStorage) UpdateSessionData ¶
type ServerlessSessionStorage ¶
type ServerlessSessionStorage struct {
// contains filtered or unexported fields
}
func NewMemorySessionStorage ¶
func (ServerlessSessionStorage) AddLoginInfo ¶
func (*ServerlessSessionStorage) Close ¶
func (s *ServerlessSessionStorage) Close()
func (*ServerlessSessionStorage) FindBySessionToken ¶
func (*ServerlessSessionStorage) GetUserSessions ¶
func (s *ServerlessSessionStorage) GetUserSessions(ctx context.Context, userID string) ([]SingleSessionData, error)
func (ServerlessSessionStorage) Logout ¶
func (s ServerlessSessionStorage) Logout(ctx context.Context, sessionID string) error
func (ServerlessSessionStorage) RenewSession ¶
func (ServerlessSessionStorage) StartLogin ¶
func (*ServerlessSessionStorage) StartSession ¶
func (ServerlessSessionStorage) UpdateSessionData ¶
type Session ¶
type Session struct { LoginAt UnixTime `json:"login_at"` ExpireAt UnixTime `json:"expire_at"` LastAccessAt UnixTime `json:"last_access_at"` UserID string `json:"id"` DisplayName string `json:"name"` Email string `json:"email"` Organization string `json:"org"` Scopes []string `json:"scopes"` Status SessionStatus `json:"-"` Data map[string]string `json:"data"` // contains filtered or unexported fields }
func (*Session) AddSessionData ¶
func (*Session) RemoveSessionData ¶
type SessionStatus ¶
type SessionStatus int
const ( BeforeLogin SessionStatus = iota ActiveSession IdleTimeoutSession AbsoluteTimeoutSession // This is not used )
type SessionStorage ¶
type SessionStorage interface { // StartLogin is called before login session // info keeps information like redirect URL StartLogin(ctx context.Context, info map[string]string) (sessionID string, err error) // AddLoginInfo adds extra login information for IDP. AddLoginInfo(ctx context.Context, oldSessionID string, info map[string]string) (newSessionID string, err error) // startSessionAndRedirect is called after authorization and it renews login session ID and return info that is stored in StartLogin StartSession(ctx context.Context, oldSessionID string, user *User, r *http.Request, newLoginInfo map[string]string) (newSessionID string, info map[string]string, err error) Logout(ctx context.Context, sessionID string) error GetUserSessions(ctx context.Context, userID string) ([]SingleSessionData, error) FindBySessionToken(ctx context.Context, sessionID string) (*Session, error) UpdateSessionData(ctx context.Context, sessionID string, directives []*Directive) (err error) RenewSession(ctx context.Context, oldSessionID string) (sessionID string, err error) }
func NewSessionStorage ¶
type SingleSessionData ¶
type SingleSessionData struct { ID string `docstore:"id" json:"-"` UserID string `docstore:"user_id" json:"-"` LoginAt time.Time `docstore:"login_at" json:"login_at"` LastAccessAt time.Time `docstore:"last_access_at" json:"last_access_at"` CurrentSession bool `docstore:"-" json:"current"` LoginInfo map[string]string `docstore:"loginInfo" json:"login_info"` }
func (SingleSessionData) Browser ¶
func (s SingleSessionData) Browser() string
func (SingleSessionData) IdP ¶
func (s SingleSessionData) IdP() string
func (SingleSessionData) LastAccessAtForHuman ¶
func (s SingleSessionData) LastAccessAtForHuman() string
func (SingleSessionData) LastAccessAtFormat ¶
func (s SingleSessionData) LastAccessAtFormat() string
func (SingleSessionData) Location ¶
func (s SingleSessionData) Location() string
func (SingleSessionData) LoginAtForHuman ¶
func (s SingleSessionData) LoginAtForHuman() string
func (SingleSessionData) LoginAtFormat ¶
func (s SingleSessionData) LoginAtFormat() string
func (SingleSessionData) OS ¶
func (s SingleSessionData) OS() string
type TwitterConfig ¶
func (TwitterConfig) Available ¶
func (c TwitterConfig) Available() bool
type UnixTime ¶
func (UnixTime) MarshalJSON ¶
type User ¶
type User struct { DisplayName string `json:"display_name"` Organization string `json:"organization"` UserID string `json:"user_id"` Email string `json:"email"` Scopes []string `json:"scopes"` FederatedUserAccounts []FederatedAccount `json:"federated_accounts"` }
func (User) ScopeString ¶
type UserSession ¶
type UserSession struct { ID string `docstore:"id"` Sessions []string `docstore:"singleSessions"` Data map[string]string `docstore:"data"` // User Informations DisplayName string `docstore:"name"` Email string `docstore:"email"` Organization string `docstore:"org"` Scopes []string `docstore:"scopes"` }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.