auth-backend: throw error if sign-in result does not contain token when preparting identity response

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2023-07-13 21:57:08 +02:00
parent e19e04eab0
commit 1c522713cd
@@ -14,6 +14,7 @@
* limitations under the License.
*/
import { InputError } from '@backstage/errors';
import {
BackstageIdentityResponse,
BackstageSignInResult,
@@ -34,6 +35,10 @@ function parseJwtPayload(token: string) {
export function prepareBackstageIdentityResponse(
result: BackstageSignInResult,
): BackstageIdentityResponse {
if (!result.token) {
throw new InputError(`Identity response must return a token`);
}
const { sub, ent } = parseJwtPayload(result.token);
return {