namespaceAuthorizes static method

bool namespaceAuthorizes(
  1. Map<String, dynamic> approvedNamespaces,
  2. String namespace
)

Whether an enrollment approved for approvedNamespaces (a map of namespace -> access, as carried by an enrollment record) is authorized for namespace.

Mirrors the atServer's rule: authorized when an approved namespace is *, equals namespace, or is a dot-suffix of it (an enrollment approved for myapp may access data.myapp).

Implementation

static bool namespaceAuthorizes(
    Map<String, dynamic> approvedNamespaces, String namespace) {
  for (final approved in approvedNamespaces.keys) {
    if (approved == '*' ||
        approved == namespace ||
        namespace.endsWith('.$approved')) {
      return true;
    }
  }
  return false;
}