aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middleware/context_keys.go
diff options
context:
space:
mode:
authorGravatar Frédéric Guillot <fred@miniflux.net>2017-12-16 18:07:53 -0800
committerGravatar Frédéric Guillot <fred@miniflux.net>2017-12-16 18:07:53 -0800
commit00257988ef1707a028cd7dd0b1f8f68e6e8fac53 (patch)
treef54ccd93abb5054336baea1f0a4a99f8700fc81a /server/middleware/context_keys.go
parent58acd1d5e3a997d27f60549b51bdf41df900c6c6 (diff)
Session management refactoring
Diffstat (limited to 'server/middleware/context_keys.go')
-rw-r--r--server/middleware/context_keys.go34
1 files changed, 27 insertions, 7 deletions
diff --git a/server/middleware/context_keys.go b/server/middleware/context_keys.go
index 3099322..31ad286 100644
--- a/server/middleware/context_keys.go
+++ b/server/middleware/context_keys.go
@@ -4,23 +4,43 @@
package middleware
-type contextKey struct {
+// ContextKey represents a context key.
+type ContextKey struct {
name string
}
+func (c ContextKey) String() string {
+ return c.name
+}
+
var (
// UserIDContextKey is the context key used to store the user ID.
- UserIDContextKey = &contextKey{"UserID"}
+ UserIDContextKey = &ContextKey{"UserID"}
// UserTimezoneContextKey is the context key used to store the user timezone.
- UserTimezoneContextKey = &contextKey{"UserTimezone"}
+ UserTimezoneContextKey = &ContextKey{"UserTimezone"}
// IsAdminUserContextKey is the context key used to store the user role.
- IsAdminUserContextKey = &contextKey{"IsAdminUser"}
+ IsAdminUserContextKey = &ContextKey{"IsAdminUser"}
// IsAuthenticatedContextKey is the context key used to store the authentication flag.
- IsAuthenticatedContextKey = &contextKey{"IsAuthenticated"}
+ IsAuthenticatedContextKey = &ContextKey{"IsAuthenticated"}
+
+ // UserSessionTokenContextKey is the context key used to store the user session ID.
+ UserSessionTokenContextKey = &ContextKey{"UserSessionToken"}
+
+ // SessionIDContextKey is the context key used to store the session ID.
+ SessionIDContextKey = &ContextKey{"SessionID"}
+
+ // CSRFContextKey is the context key used to store CSRF token.
+ CSRFContextKey = &ContextKey{"CSRF"}
+
+ // OAuth2StateContextKey is the context key used to store OAuth2 state.
+ OAuth2StateContextKey = &ContextKey{"OAuth2State"}
+
+ // FlashMessageContextKey is the context key used to store a flash message.
+ FlashMessageContextKey = &ContextKey{"FlashMessage"}
- // TokenContextKey is the context key used to store CSRF token.
- TokenContextKey = &contextKey{"CSRF"}
+ // FlashErrorMessageContextKey is the context key used to store a flash error message.
+ FlashErrorMessageContextKey = &ContextKey{"FlashErrorMessage"}
)