Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 (
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;
})));
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}`,
},
};
}
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 });
}
});
};
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 });
});
};
scopesUnion.forEach(scope => {
const s1 = scopeIntersection([scope], scopesA);
const s2 = scopeIntersection([scope], scopesB);
scopesetDiff.push([s1, s2]);
});
scopesUnion.forEach(scope => {
const s1 = scopeIntersection([scope], scopesA);
const s2 = scopeIntersection([scope], scopesB);
scopesetDiff.push([s1, s2]);
});
scopesUnion.forEach(scope => {
const s1 = scopeIntersection([scope], scopesA);
const s2 = scopeIntersection([scope], scopesB);
scopesetDiff.push([s1, s2]);
});
scopesUnion.forEach(scope => {
const s1 = scopeIntersection([scope], scopesA);
const s2 = scopeIntersection([scope], scopesB);
scopesetDiff.push([s1, s2]);
});