Documentation ¶
Index ¶
- Variables
- func SetCookieSession(key string, r *http.Request)
- type Service
- func (s *Service) CreateSession(ctx context.Context, user string) (*influxdb.Session, error)
- func (s *Service) ExpireSession(ctx context.Context, key string) error
- func (s *Service) FindSession(ctx context.Context, key string) (*influxdb.Session, error)
- func (s *Service) RenewSession(ctx context.Context, session *influxdb.Session, newExpiration time.Time) error
- func (s *Service) WithMaxPermissionFunc(fn func(context.Context) bool)
- type ServiceOption
- type SessionHandler
- type SessionLogger
- func (l *SessionLogger) CreateSession(ctx context.Context, user string) (s *influxdb.Session, err error)
- func (l *SessionLogger) ExpireSession(ctx context.Context, key string) (err error)
- func (l *SessionLogger) FindSession(ctx context.Context, key string) (session *influxdb.Session, err error)
- func (l *SessionLogger) RenewSession(ctx context.Context, session *influxdb.Session, newExpiration time.Time) (err error)
- type SessionMetrics
- func (m *SessionMetrics) CreateSession(ctx context.Context, user string) (s *influxdb.Session, err error)
- func (m *SessionMetrics) ExpireSession(ctx context.Context, key string) (err error)
- func (m *SessionMetrics) FindSession(ctx context.Context, key string) (session *influxdb.Session, err error)
- func (m *SessionMetrics) RenewSession(ctx context.Context, session *influxdb.Session, newExpiration time.Time) (err error)
- type Storage
- func (s *Storage) CreateSession(ctx context.Context, session *influxdb.Session) error
- func (s *Storage) DeleteSession(ctx context.Context, id influxdb.ID) error
- func (s *Storage) FindSessionByID(ctx context.Context, id influxdb.ID) (*influxdb.Session, error)
- func (s *Storage) FindSessionByKey(ctx context.Context, key string) (*influxdb.Session, error)
- func (s *Storage) RefreshSession(ctx context.Context, id influxdb.ID, expireAt time.Time) error
- type Store
Constants ¶
This section is empty.
Variables ¶
var ( // usually due to password missmatch ErrUnauthorized = &influxdb.Error{ Code: influxdb.EUnauthorized, Msg: "unauthorized access", } )
Functions ¶
func SetCookieSession ¶
SetCookieSession adds a cookie for the session to an http request
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service implements the influxdb.SessionService interface and handles communication between session and the necessary user and urm services
func NewService ¶
func NewService(store *Storage, userService influxdb.UserService, urmService influxdb.UserResourceMappingService, authSvc influxdb.AuthorizationService, opts ...ServiceOption) *Service
NewService creates a new session service
func (*Service) CreateSession ¶
CreateSession
func (*Service) ExpireSession ¶
ExpireSession removes a session from the system
func (*Service) FindSession ¶
FindSession finds a session based on the session key
type ServiceOption ¶
type ServiceOption func(*Service)
ServiceOption is a functional option for configuring a *Service
func WithIDGenerator ¶
func WithIDGenerator(gen influxdb.IDGenerator) ServiceOption
WithIDGenerator overrides the default ID generator with the one provided to this function when called on a *Service
func WithSessionLength ¶
func WithSessionLength(length time.Duration) ServiceOption
WithSessionLength configures the length of the session with the provided duration when the resulting option is called on a *Service.
func WithTokenGenerator ¶
func WithTokenGenerator(gen influxdb.TokenGenerator) ServiceOption
WithTokenGenerator overrides the default token generator with the one provided to this function when called on a *Service
type SessionHandler ¶
SessionHandler represents an HTTP API handler for authorizations.
func NewSessionHandler ¶
func NewSessionHandler(log *zap.Logger, sessionSvc influxdb.SessionService, userSvc influxdb.UserService, passwordsSvc influxdb.PasswordsService) *SessionHandler
NewSessionHandler returns a new instance of SessionHandler.
func (SessionHandler) SignInResourceHandler ¶
func (h SessionHandler) SignInResourceHandler() *resourceHandler
SignInResourceHandler allows us to return 2 different rousource handler for the appropriate mounting location
func (SessionHandler) SignOutResourceHandler ¶
func (h SessionHandler) SignOutResourceHandler() *resourceHandler
SignOutResourceHandler allows us to return 2 different rousource handler for the appropriate mounting location
type SessionLogger ¶
type SessionLogger struct {
// contains filtered or unexported fields
}
SessionLogger is a logger service middleware for sessions
func NewSessionLogger ¶
func NewSessionLogger(log *zap.Logger, s influxdb.SessionService) *SessionLogger
NewSessionLogger returns a logging service middleware for the User Service.
func (*SessionLogger) CreateSession ¶
func (l *SessionLogger) CreateSession(ctx context.Context, user string) (s *influxdb.Session, err error)
CreateSession calls the underlying session service and logs the results of the request
func (*SessionLogger) ExpireSession ¶
func (l *SessionLogger) ExpireSession(ctx context.Context, key string) (err error)
ExpireSession calls the underlying session service and logs the results of the request
func (*SessionLogger) FindSession ¶
func (l *SessionLogger) FindSession(ctx context.Context, key string) (session *influxdb.Session, err error)
FindSession calls the underlying session service and logs the results of the request
func (*SessionLogger) RenewSession ¶
func (l *SessionLogger) RenewSession(ctx context.Context, session *influxdb.Session, newExpiration time.Time) (err error)
RenewSession calls the underlying session service and logs the results of the request
type SessionMetrics ¶
type SessionMetrics struct {
// contains filtered or unexported fields
}
SessionMetrics is a metrics middleware system for the session service
func NewSessionMetrics ¶
func NewSessionMetrics(reg prometheus.Registerer, s influxdb.SessionService) *SessionMetrics
NewSessionMetrics creates a new session metrics middleware
func (*SessionMetrics) CreateSession ¶
func (m *SessionMetrics) CreateSession(ctx context.Context, user string) (s *influxdb.Session, err error)
CreateSession calls the underlying session service and tracks RED metrics for the call
func (*SessionMetrics) ExpireSession ¶
func (m *SessionMetrics) ExpireSession(ctx context.Context, key string) (err error)
ExpireSession calls the underlying session service and tracks RED metrics for the call
func (*SessionMetrics) FindSession ¶
func (m *SessionMetrics) FindSession(ctx context.Context, key string) (session *influxdb.Session, err error)
FindSession calls the underlying session service and tracks RED metrics for the call
func (*SessionMetrics) RenewSession ¶
func (m *SessionMetrics) RenewSession(ctx context.Context, session *influxdb.Session, newExpiration time.Time) (err error)
RenewSession calls the underlying session service and tracks RED metrics for the call
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage is a store translation layer between the data storage unit and the service layer.
func (*Storage) CreateSession ¶
CreateSession creates a new session
func (*Storage) DeleteSession ¶
DeleteSession removes the session and index from storage
func (*Storage) FindSessionByID ¶
FindSessionByID use a provided id to retrieve the stored session
func (*Storage) FindSessionByKey ¶
FindSessionByKey use a given key to retrieve the stored session