authenticate method
Authenticates request. See the class contract for the return/throw
semantics.
Implementation
@override
Future<Principal?> authenticate(HubRequest request) async {
final header = request.header('authorization');
if (header == null) return null;
final parts = header.split(' ');
if (parts.length != 2 || parts[0].toLowerCase() != 'bearer') return null;
final principal = await _resolve(parts[1]);
if (principal == null) {
throw const UnauthorizedException('Invalid bearer token');
}
return principal;
}