How to use the taskcluster-lib-scopes.removeGivenScopes function in taskcluster-lib-scopes

To help you get started, we’ve selected a few taskcluster-lib-scopes examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github taskcluster / taskcluster / infrastructure / tooling / src / smoketest / index.js View on Github external
!process.env.TASKCLUSTER_CLIENT_ID ||
    !process.env.TASKCLUSTER_ACCESS_TOKEN
  ) {
    console.log([
      'Must provide TASKCLUSTER_ROOT_URL, TASKCLUSTER_CLIENT_ID, and TASKCLUSTER_ACCESS_TOKEN as',
      'environment variables. We recommend using signin from:',
      '',
      'https://github.com/taskcluster/taskcluster/tree/master/clients/client-shell#taskcluster-shell-client',
    ].join('\n'));
    process.exit(1);
  }

  const auth = new taskcluster.Auth(taskcluster.fromEnvVars());
  const res = await auth.currentScopes();
  if (!libScopes.satisfiesExpression(res.scopes, scopeExpression)) {
    const required = libScopes.removeGivenScopes(res.scopes, scopeExpression);
    const message = [
      'The provided Taskcluster credentials are missing the following scopes:',
      '',
      JSON.stringify(required, null, 2),
      '',
      'The credentials must satisfy the following expression:',
      '',
      JSON.stringify(scopeExpression, null, 2),
    ].join('\n');
    console.log(message);
    process.exit(1);
  }

  const target = options.target ? [`target-${options.target}`] : undefined;
  const taskgraph = new TaskGraph(checks, {target});
  await taskgraph.run();
github taskcluster / taskcluster / libraries / api / src / middleware / auth.js View on Github external
'You have the scopes:',
              '',
              '```',
              '{{scopes}}',
              '```',
              '',
              'This request requires you to satisfy this scope expression:',
              '',
              '```',
              '{{required}}',
              '```',
            ].join('\n'),
            details: {
              scopes: result.scopes,
              required: scopeExpression,
              unsatisfied: scopes.removeGivenScopes(result.scopes, scopeExpression),
            },
          });
        }
        req.satisfyingScopes = satisfyingScopes;
      };