dart_frog_auth 1.2.0 copy "dart_frog_auth: ^1.2.0" to clipboard
dart_frog_auth: ^1.2.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
points
1.9k
downloads

Publisher

verified publisherverygood.ventures

Weekly Downloads

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

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#server #backend #dart-frog #authentication #middleware

Documentation

Documentation
API reference

License

MIT (license)

Dependencies

dart_frog

More

Packages that depend on dart_frog_auth