authenticateRequest static method

Future<DVApiAuthentication> authenticateRequest(
  1. String? authorization
)

The authentication stage for a request whose Authorization header is authorization, on the tenant the request resolved to.

Without an installed platform API a platform credential is refused with 503 rather than ignored: ignoring it would hand the route a request its caller believes is authenticated and nothing checked.

Implementation

static Future<DVApiAuthentication> authenticateRequest(
  String? authorization,
) async {
  if (credentialOf(authorization) == null) return DVApiAuthentication.none;
  final DVPlatformApi? platform = _installed;
  if (platform == null) {
    return const DVApiAuthentication.refused(503, 'Service Unavailable');
  }
  return platform.authenticate(authorization);
}