Use request options
This commit is contained in:
@@ -30,7 +30,7 @@ describe('CatalogIdentityClient', () => {
|
||||
catalogClient: new MockedCatalogClient(),
|
||||
});
|
||||
|
||||
client.findUser(token, { annotations: { key: 'value' } });
|
||||
client.findUser({ annotations: { key: 'value' } }, { token });
|
||||
|
||||
const getEntities = MockedCatalogClient.mock.instances[0].getEntities;
|
||||
expect(getEntities).toHaveBeenCalledWith(
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
import { ConflictError, NotFoundError } from '@backstage/backend-common';
|
||||
import { CatalogClient } from '@backstage/catalog-client';
|
||||
import { UserEntity } from '@backstage/catalog-model';
|
||||
import { CatalogIdentityRequestOptions } from './types';
|
||||
|
||||
type UserQuery = {
|
||||
annotations: Record<string, string>;
|
||||
@@ -38,9 +39,10 @@ export class CatalogIdentityClient {
|
||||
* Throws a NotFoundError or ConflictError if 0 or multiple users are found.
|
||||
*/
|
||||
async findUser(
|
||||
token: string | undefined,
|
||||
query: UserQuery,
|
||||
options?: CatalogIdentityRequestOptions,
|
||||
): Promise<UserEntity> {
|
||||
const token = options?.token;
|
||||
const filter: Record<string, string> = {
|
||||
kind: 'user',
|
||||
};
|
||||
|
||||
@@ -157,11 +157,14 @@ export class GoogleAuthProvider implements OAuthHandlers {
|
||||
const token = await this.tokenIssuer.issueToken({
|
||||
claims: { sub: 'backstage.io/auth-backend' },
|
||||
});
|
||||
const user = await this.identityClient.findUser(token, {
|
||||
annotations: {
|
||||
'google.com/email': profile.email,
|
||||
const user = await this.identityClient.findUser(
|
||||
{
|
||||
annotations: {
|
||||
'google.com/email': profile.email,
|
||||
},
|
||||
},
|
||||
});
|
||||
{ token },
|
||||
);
|
||||
|
||||
return {
|
||||
...response,
|
||||
|
||||
Reference in New Issue
Block a user