Documentation
¶
Index ¶
- func ExtendSession(sessionStore sessionstore.StoreInterface, r *http.Request, seconds int64) error
- func GetAPIAuthUser(r *http.Request) userstore.UserInterface
- func GetAPIAuthUserFromContext(ctx context.Context) userstore.UserInterface
- func GetAuthSession(r *http.Request) sessionstore.SessionInterface
- func GetAuthSessionFromContext(ctx context.Context) sessionstore.SessionInterface
- func GetAuthUser(r *http.Request) userstore.UserInterface
- func GetAuthUserFromContext(ctx context.Context) userstore.UserInterface
- func SetAPIAuthUser(r *http.Request, user userstore.UserInterface) *http.Request
- func SetAPIAuthUserInContext(ctx context.Context, user userstore.UserInterface) context.Context
- func SetAuthSession(r *http.Request, session sessionstore.SessionInterface) *http.Request
- func SetAuthSessionInContext(ctx context.Context, session sessionstore.SessionInterface) context.Context
- func SetAuthUser(r *http.Request, user userstore.UserInterface) *http.Request
- func SetAuthUserInContext(ctx context.Context, user userstore.UserInterface) context.Context
- func UserSettingGet(sessionStore sessionstore.StoreInterface, r *http.Request, key string, ...) string
- func UserSettingSet(sessionStore sessionstore.StoreInterface, r *http.Request, key string, ...) error
- type APIAuthenticatedUserContextKey
- type AuthenticatedSessionContextKey
- type AuthenticatedUserContextKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtendSession ¶
func ExtendSession(sessionStore sessionstore.StoreInterface, r *http.Request, seconds int64) error
ExtendSession extends an authenticated session by the specified number of seconds. It validates that the session IP address and user agent match the current request before extending the session expiration time.
func GetAPIAuthUser ¶
func GetAPIAuthUser(r *http.Request) userstore.UserInterface
GetAPIAuthUser returns the authenticated user for API context. It retrieves the user that was previously stored in the context using the APIAuthenticatedUserContextKey.
func GetAPIAuthUserFromContext ¶
func GetAPIAuthUserFromContext(ctx context.Context) userstore.UserInterface
GetAPIAuthUserFromContext returns the API authenticated user from a context. This is useful when you have a context but not the original request.
func GetAuthSession ¶
func GetAuthSession(r *http.Request) sessionstore.SessionInterface
GetAuthSession returns the authenticated session from the request context. It retrieves the session that was previously stored in the context using the AuthenticatedSessionContextKey.
func GetAuthSessionFromContext ¶
func GetAuthSessionFromContext(ctx context.Context) sessionstore.SessionInterface
GetAuthSessionFromContext returns the authenticated session from a context. This is useful when you have a context but not the original request.
func GetAuthUser ¶
func GetAuthUser(r *http.Request) userstore.UserInterface
GetAuthUser returns the authenticated user from the request context. It retrieves the user that was previously stored in the context using the AuthenticatedUserContextKey.
func GetAuthUserFromContext ¶
func GetAuthUserFromContext(ctx context.Context) userstore.UserInterface
GetAuthUserFromContext returns the authenticated user from a context. This is useful when you have a context but not the original request.
func SetAPIAuthUser ¶
SetAPIAuthUser sets the API authenticated user in the request context. This is typically used by API authentication middleware to store the user after successful authentication.
func SetAPIAuthUserInContext ¶
SetAPIAuthUserInContext sets the API authenticated user in the context. Returns a new context with the user stored.
func SetAuthSession ¶
func SetAuthSession(r *http.Request, session sessionstore.SessionInterface) *http.Request
SetAuthSession sets the authenticated session in the request context. This is typically used by authentication middleware to store the session after successful authentication.
func SetAuthSessionInContext ¶
func SetAuthSessionInContext(ctx context.Context, session sessionstore.SessionInterface) context.Context
SetAuthSessionInContext sets the authenticated session in the context. Returns a new context with the session stored.
func SetAuthUser ¶
SetAuthUser sets the authenticated user in the request context. This is typically used by authentication middleware to store the user after successful authentication.
func SetAuthUserInContext ¶
SetAuthUserInContext sets the authenticated user in the context. Returns a new context with the user stored.
func UserSettingGet ¶
func UserSettingGet(sessionStore sessionstore.StoreInterface, r *http.Request, key string, defaultValue string) string
UserSettingGet retrieves a user-specific setting from session storage. It validates that the setting belongs to the authenticated user and matches the current request IP and user agent for security.
func UserSettingSet ¶
func UserSettingSet(sessionStore sessionstore.StoreInterface, r *http.Request, key string, value string) error
UserSettingSet stores a user-specific setting in session storage. It creates or updates a session with the provided key-value pair and sets a 1-hour expiration time. Validates user ownership and request security.
Types ¶
type APIAuthenticatedUserContextKey ¶
type APIAuthenticatedUserContextKey struct{}
APIAuthenticatedUserContextKey is the context key used to store the API authenticated user
type AuthenticatedSessionContextKey ¶
type AuthenticatedSessionContextKey struct{}
AuthenticatedSessionContextKey is the context key used to store the authenticated session
type AuthenticatedUserContextKey ¶
type AuthenticatedUserContextKey struct{}
AuthenticatedUserContextKey is the context key used to store the authenticated user