dart_frog_header_auth

Pub Package GitHub

Header-based authentication middleware for Dart Frog applications.

Overview

This package provides middleware for header-based authentication in Dart Frog applications. It validates user tokens from a specified header and makes the authenticated user available to handlers.

Usage

To use this middleware, you can include it in your Dart Frog application as follows:

import 'package:dart_frog_header_auth/dart_frog_header_auth.dart';

Handler handleHeaderAuth(Handler handler) {
  return handler.use(requestLogger()).use(
    headerAuthentication<User>(
      authenticator: (context, token) async {
        final userRepository = context.read<UserRepository>();
        return await userRepository.userFromToken(token);
      },
    ),
  );
}

Documentation

For detailed documentation and examples, refer to the API Documentation.

Installation

Add the following to your pubspec.yaml:

dependencies:
  dart_frog_header_auth: ^latest_version

Replace ^latest_version with the latest version from pub.dev.

Changelog

For a complete list of changes, see the Changelog.

License

This project is licensed under the MIT License - see the LICENSE file for details.