pharaoh_jwt_auth 1.0.0+2 copy "pharaoh_jwt_auth: ^1.0.0+2" to clipboard
pharaoh_jwt_auth: ^1.0.0+2 copied to clipboard

Pharaoh middleware that validates a JsonWebToken (JWT) and set the req.auth with the attributes

pharaoh_jwt_auth 🪭 #

This module provides Pharaoh middleware for validating JWTs (JSON Web Tokens) through the dart_jsonwebtoken package.

The decoded JWT payload is available on the request object via req.auth.

Installing: #

In your pubspec.yaml

dependencies:
  pharaoh: ^0.0.5+6
  pharaoh_jwt_auth:

Basic Usage: #

import 'package:pharaoh/pharaoh.dart';
import 'package:pharaoh_jwt_auth/pharaoh_jwt_auth.dart';

void main() async {
  final app = Pharaoh();

  app.use(jwtAuth(secret: () => SecretKey('some-secret-key')));

  app.get('/', (req, res) => res.ok('Hello World'));

  await app.listen();
}

The package also exports the dart_jsonwebtoken package for your usage outside of this library.

Tests #

The cases in the pharaoh_jwt_auth_test.dart are also used for automated testing. So if you want
to contribute or just make sure that the package still works, simply run:

dart test
1
likes
130
pub points
0%
popularity

Publisher

unverified uploader

Pharaoh middleware that validates a JsonWebToken (JWT) and set the req.auth with the attributes

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

dart_jsonwebtoken, pharaoh

More

Packages that depend on pharaoh_jwt_auth