Line data Source code
1 : import 'dart:convert';
2 : import 'dart:io';
3 :
4 : import 'package:agattp/src/auth/agattp_abstract_auth.dart';
5 :
6 : /// Implementation of the Basic Auth authentication strategy
7 : class AgattpAuthBasic implements AgattpAuthInterface {
8 : /// The Basic Auth username
9 : final String username;
10 :
11 : /// The Basic Auth password
12 : final String password;
13 :
14 1 : const AgattpAuthBasic({
15 : required this.username,
16 : required this.password,
17 : });
18 :
19 1 : @override
20 1 : Future<Map<String, String>> getAuthHeaders(_, __) async => <String, String>{
21 : // Simply encode the username and password in base64
22 : HttpHeaders.authorizationHeader:
23 6 : 'Basic ${base64.encode(utf8.encode('$username:$password'))}',
24 : };
25 : }
|