default id provider surface NotAllowedError

Signed-off-by: Brian Fletcher <brian@roadie.io>
This commit is contained in:
Brian Fletcher
2022-08-25 15:42:12 +01:00
parent f05f8d7e7d
commit ed92f732a1
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { PluginEndpointDiscovery } from '@backstage/backend-common';
import { AuthenticationError } from '@backstage/errors';
import { AuthenticationError, NotAllowedError } from '@backstage/errors';
import {
createRemoteJWKSet,
decodeJwt,
@@ -81,9 +81,13 @@ export class DefaultIdentityClient implements IdentityApi {
if (!request.headers.authorization) {
return undefined;
}
return await this.authenticate(
getBearerTokenFromAuthorizationHeader(request.headers.authorization),
);
try {
return await this.authenticate(
getBearerTokenFromAuthorizationHeader(request.headers.authorization),
);
} catch (e) {
throw new NotAllowedError('Failed to authenticate the provided token');
}
}
/**