dart_frog_auth 1.0.0 copy "dart_frog_auth: ^1.0.0" to clipboard
dart_frog_auth: ^1.0.0 copied to clipboard

Header authentication based middlewares for Dart Frog. Built by Very Good Ventures.

example/README.md

Example #

Use basicAuthentication to add basic authentication to your routes:

// routes/admin/_middleware.dart
import 'package:dart_frog/dart_frog.dart';
import 'package:dart_frog_auth/dart_frog_auth.dart';
import 'package:blog/user.dart';

Handler middleware(Handler handler) {
  final userRepository = ...;
  return handler
      .use(requestLogger())
      .use(
        basicAuthentication<User>(
          userFromCredentials: userRepository.fetchFromCredentials,
        ),
      );
}

User bearerAuthentication to add bearer token authentication to your routes:

// routes/admin/_middleware.dart
import 'package:dart_frog/dart_frog.dart';
import 'package:dart_frog_auth/dart_frog_auth.dart';
import 'package:blog/user.dart';

Handler middleware(Handler handler) {
  final userRepository = ...;
  return handler
      .use(requestLogger())
      .use(
        bearerAuthentication<User>(
          userFromToken: userRepository.fetchFromAccessToken,
        ),
      );
}
29
likes
160
pub points
89%
popularity

Publisher

verified publisherverygood.ventures

Header authentication based middlewares for Dart Frog. Built by Very Good Ventures.

Homepage
Repository (GitHub)
View/report issues
Contributing

Documentation

Documentation
API reference

License

MIT (license)

Dependencies

dart_frog

More

Packages that depend on dart_frog_auth