Merge pull request #14030 from angathorion/have-permissions-authorize-api-return-401-on-invalid-token

Fix permissions API to return 401 instead of 500 on throw
This commit is contained in:
Johan Haals
2022-10-17 10:13:01 +02:00
committed by GitHub
2 changed files with 7 additions and 2 deletions
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { PluginEndpointDiscovery } from '@backstage/backend-common';
import { AuthenticationError, NotAllowedError } from '@backstage/errors';
import { AuthenticationError } from '@backstage/errors';
import {
createRemoteJWKSet,
decodeJwt,
@@ -86,7 +86,7 @@ export class DefaultIdentityClient implements IdentityApi {
getBearerTokenFromAuthorizationHeader(request.headers.authorization),
);
} catch (e) {
throw new NotAllowedError(e.message);
throw new AuthenticationError(e.message);
}
}