How to use the taskcluster-lib-scopes.scopeIntersection 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 / ui / src / views / Clients / ViewClient / index.jsx View on Github external
disabled: false,
    };
    const isCliLogin = Boolean(query.callback_url);
    const isClientDisabled =
      clientData && clientData.client && clientData.client.disabled;

    // CLI login
    if (
      isCliLogin &&
      user &&
      currentScopesData &&
      currentScopesData.currentScopes
    ) {
      Object.assign(initialClient, {
        clientId: `${user.credentials.clientId}/${query.name}`,
        scopes: scopeIntersection(
          initialClient.scopes,
          currentScopesData.currentScopes
        ),
      });
    }

    if (location.state && location.state.accessToken) {
      const state = { ...location.state };

      delete state.accessToken;
      this.props.history.replace({ state });
    }

    return (
github taskcluster / taskcluster / services / web-server / src / servers / oauth2.js View on Github external
const currentUser = await strategies[user.identityProviderId].userFromIdentity(user.identity);

    const userScopes = (await auth.expandScopes({scopes: currentUser.scopes()})).scopes;

    await AccessToken.create({
      // OAuth2 client
      clientId: registeredClient.clientId,
      redirectUri: areq.redirectURI,
      identity: user.identity,
      identityProviderId: user.identityProviderId,
      accessToken: accessToken,
      expires: taskcluster.fromNow('10 minutes'),
      clientDetails: {
        clientId: ares.clientId,
        description: ares.description || `Client generated by ${user.identity} for OAuth2 Client ${registeredClient.clientId}`,
        scopes: scopeIntersection(ares.scope, userScopes),
        expires: ares.expires ?
          ares.expires > taskcluster.fromNow(registeredClient.maxExpires) ?
            taskcluster.fromNow(registeredClient.maxExpires).toISOString() :
            ares.expires.toISOString()
          : taskcluster.fromNow(registeredClient.maxExpires).toISOString(),
        deleteOnExpiration: true,
      },
    }, true);

    return accessToken;
  })));
github taskcluster / taskcluster / ui / src / views / ThirdPartyLogin / index.jsx View on Github external
const scopes = (query.scope || []).split(' ');
    const registeredClientId = query.client_id;

    if (
      !data ||
      state.formData ||
      !(data.currentScopes instanceof Array) ||
      !query.transactionID
    ) {
      return null;
    }

    return {
      formData: {
        ...state.formData,
        scopes: scopeIntersection(scopes, data.currentScopes),
        expires: fromNowJSON(query.expires),
        description: `Client generated by ${user.credentials.clientId} for OAuth2 Client ${registeredClientId}`,
      },
    };
  }
github taskcluster / taskcluster-tools / src / views / ClientCreator / ClientCreator.jsx View on Github external
this.setState({ loading: true }, async () => {
      try {
        const description =
          this.state.query.description ||
          `Client created ${new Date()} for ${this.state.query.callback_url}`;
        const requestedScopes = toArray(this.state.query.scope);
        const currentScopes = (await this.props.auth.currentScopes()).scopes;

        await this.props.auth.updateClient(this.state.client.clientId, {
          description,
          expires: fromNow(this.state.query.expires || '3 days'),
          scopes: scopeIntersection(currentScopes, requestedScopes),
          deleteOnExpiration: true
        });

        const client = await this.props.auth.resetAccessToken(
          this.state.client.clientId
        );

        this.triggerCallback(client.clientId, client.accessToken);
      } catch (error) {
        this.setState({ error, loading: false });
      }
    });
  };
github taskcluster / taskcluster-tools / src / views / ClientCreator / ClientCreator.jsx View on Github external
this.setState({ loading: true }, async () => {
      const currentScopes = await this.props.auth.currentScopes();
      const client = await this.constructClient(
        `${this.state.clientPrefix}/${this.state.query.name}`
      );

      client.scopes = scopeIntersection(client.scopes, currentScopes.scopes);

      this.setState({ client, creating: true, loading: false });
    });
  };
github taskcluster / taskcluster / ui / src / views / Scopes / ScopesetComparison / index.jsx View on Github external
scopesUnion.forEach(scope => {
      const s1 = scopeIntersection([scope], scopesA);
      const s2 = scopeIntersection([scope], scopesB);

      scopesetDiff.push([s1, s2]);
    });
github taskcluster / taskcluster / src / views / Scopes / ScopesetComparison / index.jsx View on Github external
scopesUnion.forEach(scope => {
      const s1 = scopeIntersection([scope], scopesA);
      const s2 = scopeIntersection([scope], scopesB);

      scopesetDiff.push([s1, s2]);
    });
github taskcluster / taskcluster / src / views / Scopes / ScopesetComparison / index.jsx View on Github external
scopesUnion.forEach(scope => {
      const s1 = scopeIntersection([scope], scopesA);
      const s2 = scopeIntersection([scope], scopesB);

      scopesetDiff.push([s1, s2]);
    });
github taskcluster / taskcluster / ui / src / views / Scopes / ScopesetComparison / index.jsx View on Github external
scopesUnion.forEach(scope => {
      const s1 = scopeIntersection([scope], scopesA);
      const s2 = scopeIntersection([scope], scopesB);

      scopesetDiff.push([s1, s2]);
    });