-
Notifications
You must be signed in to change notification settings - Fork 35
Session managers
SessionManager
is responsible for parsing, loading and saving the session data into the session store. An instance of Jaguar
server has exactly one global instance of SessionManager
. This instance is responsible for:
- Parsing the session from the request
- Loading the session from back-end (if there exists one)
- Writing back the updated session data at the end of the request chain
Jaguar
constructor takes SessionManager
using sessionManager
named parameter. By default, JaguarSessionManager
is used.
import 'package:jaguar_session_jwt/jaguar_session_jwt.dart';
main() async {
final jaguar = Jaguar(sessionManager: JwtSession(jwtConfig));
jaguar.add(reflect(LibraryApi()));
await jaguar.serve();
}
This enables adding custom session back-ends by implementing SessionManager
interface. A few such interfaces already exists to make developer's life easier:
In this article, we will explore only JaguarSessionManager
. The remaining SessionManager
s shall be discussed in upcoming articles.
JaguarSessionManager
is the default session manager used by Jaguar. It is a stateless session manager since it stores all the data on a cookie or header.
expiry
named argument configures duration after which the session expires.
It provides option to sign and verify session data for security against tampering of session data by the client. This can be configured using signerKey
named argument during construction.
final String secretKey = "dfgdgerotewrk6ertrew4567656785678ghdfghdf56745674567";
final jaguar = Jaguar(sessionManager: CookieSessionManager(signerKey: secretKey));
jaguar.add(reflect(LibraryApi()));
await jaguar.serve();
In the next article, we will learn what a JWT tokens is.
Basics
- Route handler
- Path matching
- Path parameters
- Query parameters
- Serving static files
- Cookies
- Controller
- Parameter binding
- Hot reload
Serialization
Forms
Sessions
Authentication
- Basic authentication
- Form authentication
- JSON authentication
- Authorization
- OAuth
- MongoDb
- PostgreSQL
- MySQL
- Establish connection
- ORM
- Server sent events (SSE)
- Websockets
- systemd
- Docker
- AppEngine