Documentation
¶
Index ¶
- Constants
- func AppIDInCtx(ctx context.Context) (int32, bool)
- func AppIDInCtxOrEmpty(ctx context.Context) int32
- func NewSessionMD(ap AuthProvider, ss ISessionService) func(next endpoint.Endpoint) endpoint.Endpoint
- func UserIDInCtx(ctx context.Context) (string, bool)
- func UserIDInCtxOrEmpty(ctx context.Context) string
- func WithCtxUser(ctx context.Context, user *User) context.Context
- type AuthProvider
- type AuthProviderFn
- type ISessionService
- type Session
- type User
Constants ¶
View Source
const ( SessionKey = "session_key" SessionExpires = 7 * 24 * time.Hour )
Variables ¶
This section is empty.
Functions ¶
func AppIDInCtx ¶
AppIDInCtx returns the app id from the context. Notice: NewSessionMD must be used in your service, or else this function always returns false.
func AppIDInCtxOrEmpty ¶
AppIDInCtxOrEmpty returns the app id from the context, 0 if not present.
func NewSessionMD ¶
func NewSessionMD(ap AuthProvider, ss ISessionService) func(next endpoint.Endpoint) endpoint.Endpoint
NewSessionMD creates a session middleware for Kitex.
func UserIDInCtx ¶
UserIDInCtx returns the user ID from the context. Notice: NewSessionMD must be used in your service, or else this function always returns false.
func UserIDInCtxOrEmpty ¶
UserIDInCtxOrEmpty returns the user id from the context, empty string if not present.
Types ¶
type AuthProvider ¶
type ISessionService ¶
type ISessionService interface { ValidateSession(ctx context.Context, sessionID string) (*Session, error) GenerateSessionKey(ctx context.Context, session *Session) (string, error) }
func NewSessionService ¶
func NewSessionService() ISessionService
Click to show internal directories.
Click to hide internal directories.