-
Notifications
You must be signed in to change notification settings - Fork 35
Sessions on JWT
Ravi Teja Gudapati edited this page Jan 9, 2019
·
7 revisions
Package jaguar_session_jwt provides:
-
SessionManager
to parse and store sessions from JWT -
JwtConfig
to configure - Claims to issue a token
-
HMAC private key
to issue and verify tokens -
JwtValidationConfig
to validate a token received
To store sessions as JWT instead of default Jaguar sessions, replace the default JaguarSessionManager
with an instance of JwtSession
in Jaguar
using sessionManager
parameter of constructor:
main() async {
final server = Jaguar(sessionManager: JwtSession(jwtConfig));
// add routes here
await server.serve();
}
JwtSession
can be configured using config
and validationConfig
parameters.
config
takes the information required to issue, sign and decode JWT tokens. Some of the important
parameters are:
-
issuer
: Issuer used iniss
field of JWT -
audience
: Audience used inaud
field of JWT -
maxAge
: Period for which the token is valid -
hmacKey
: The key used to sign the JWT tokens. Keep this key a secret.
const jwtConfig = const JwtConfig('sdgdflgujsdgndsflkgjsdlnwertwert78676',
issuer: 'jaguar.com');
Use io
to configure how session data is transported. Built-in options are:
-
SessionIoCookie
: Stores token in cookie -
SessionIoAuthHeader
: Stores token in authorization header -
SessionIoHeader
: Stores token in header
By default, JwtSession
uses SessionIoAuthHeader
.
TODO
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