authScimScopesAllow function

bool authScimScopesAllow(
  1. Iterable<AuthScimScope> granted,
  2. Iterable<AuthScimScope> requested
)

Whether granted permits every exact scope in requested.

Implementation

bool authScimScopesAllow(
  Iterable<AuthScimScope> granted,
  Iterable<AuthScimScope> requested,
) {
  final values = granted.toSet();
  return requested.every(
    (scope) =>
        values.contains(scope) ||
        scope == AuthScimScope.usersRead &&
            values.contains(AuthScimScope.usersWrite) ||
        scope == AuthScimScope.groupsRead &&
            values.contains(AuthScimScope.groupsWrite),
  );
}