aim_server_basic_auth 0.0.1 copy "aim_server_basic_auth: ^0.0.1" to clipboard
aim_server_basic_auth: ^0.0.1 copied to clipboard

Basic authentication middleware for Aim framework. Provides RFC 7617 compliant HTTP Basic Authentication with customizable user verification, realm support, and path exclusion.

example/main.dart

import 'dart:io';

import 'package:aim_server/aim_server.dart';
import 'package:aim_server_basic_auth/aim_server_basic_auth.dart';

void main() {
  final options = BasicAuthOptions(
    realm: 'My Protected Area',
    verify: (username, password) async {
      return username == 'admin' && password == 'password';
    },
  );
  final app = Aim<BasicAuthEnv>(envFactory: () => BasicAuthEnv(options: options));

  app.use(basicAuth());

  app.get('/protected', (c) async {
    final username = c.variables.username;
    return c.json({'message': 'Hello, $username! You have accessed a protected route.'});
  });

  app.serve(host: InternetAddress.anyIPv4, port: 8080);
}
1
likes
160
points
125
downloads

Publisher

verified publisheraim-dart.dev

Weekly Downloads

Basic authentication middleware for Aim framework. Provides RFC 7617 compliant HTTP Basic Authentication with customizable user verification, realm support, and path exclusion.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

aim_server, crypto

More

Packages that depend on aim_server_basic_auth