Use correct JWT type and algorithm

Signed-off-by: Nataliya Issayeva <nissayeva@users.noreply.github.com>
This commit is contained in:
Nataliya Issayeva
2021-11-08 13:55:01 -05:00
parent 2533294ec1
commit 7589795798
@@ -29,13 +29,13 @@ export class AuthIdentityTokenManager implements TokenManager {
discovery: discovery,
issuer: 'auth-identity-token-manager',
});
// TODO: (b2b-auth) how do we get this to be the right JWK type
this.key = JWK.asKey(Buffer.from(secret)) as JWK.OctKey;
this.key = JWK.asKey({ kty: 'oct', k: secret });
}
async getServerToken(): Promise<{ token: string }> {
// TODO: (b2b-auth) figure out how to use HMAC as the alg
const jwt = JWT.sign({ sub: 'backstage-server' }, this.key);
const jwt = JWT.sign({ sub: 'backstage-server' }, this.key, {
algorithm: 'HS256',
});
return { token: jwt };
}