gazelle_jwt 0.1.3 copy "gazelle_jwt: ^0.1.3" to clipboard
gazelle_jwt: ^0.1.3 copied to clipboard

Plugin for JSON Web Token (JWT) authentication in Gazelle, providing functionality to sign, verify, and handle JWT tokens during HTTP request processing.

Gazelle JWT Plugin #

The Gazelle JWT Plugin provides JSON Web Token (JWT) authentication capabilities for the Gazelle framework. This plugin allows you to easily secure your routes by integrating JWT-based authentication into your Gazelle application.

This plugin is based on dart_jsonwebtoken.

Getting started #

Installation #

To install the Gazelle JWT Plugin, add it to your pubspec.yaml file:

dependencies:
  gazelle_core: <latest-version>
  gazelle_jwt: <latest-version> 

Then, run dart pub get or flutter pub get to install the package.

Example usage #

Here's a quick example on how to use the GazelleJwtPlugin:

import 'package:gazelle_core/gazelle_core.dart';
import 'package:gazelle_jwt/gazelle_jwt.dart';

void main() async {
  final app = GazelleApp();
  await app.registerPlugin(GazelleJwtPlugin(SecretKey("supersecret")));

  app
    ..post(
      "/login",
      (request) async {
        return GazelleResponse(
          statusCode: 200,
          body: app.getPlugin<GazelleJwtPlugin>().sign({"test": "123"}),
        );
      },
    )
    ..get(
      "/hello_world",
      (request) async {
        return GazelleResponse(
          statusCode: 200,
          body: "Hello, World!",
        );
      },
      preRequestHooks: [app.getPlugin<GazelleJwtPlugin>().authenticationHook],
    );

  await app.start();
}
2
likes
140
pub points
0%
popularity

Publisher

verified publisherintales.it

Plugin for JSON Web Token (JWT) authentication in Gazelle, providing functionality to sign, verify, and handle JWT tokens during HTTP request processing.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

dart_jsonwebtoken, gazelle_core

More

Packages that depend on gazelle_jwt