adding express.Request back to interface
I tried to use the node-fetch request, however the express handlers appear to be passing down express.Request so its seems to be the right choice. Signed-off-by: Brian Fletcher <brian@roadie.io>
This commit is contained in:
@@ -24,6 +24,7 @@ import {
|
||||
jwtVerify,
|
||||
} from 'jose';
|
||||
import { GetKeyFunction } from 'jose/dist/types/types';
|
||||
import { Request } from 'express';
|
||||
|
||||
import { BackstageIdentityResponse } from './types';
|
||||
import { getBearerTokenFromAuthorizationHeader, IdentityApi } from '.';
|
||||
@@ -77,7 +78,7 @@ export class DefaultIdentityClient implements IdentityApi {
|
||||
async getIdentity(req: Request) {
|
||||
try {
|
||||
return await this.authenticate(
|
||||
getBearerTokenFromAuthorizationHeader(req.headers.get('authorization')),
|
||||
getBearerTokenFromAuthorizationHeader(req.headers.authorization),
|
||||
);
|
||||
} catch (e) {
|
||||
return undefined;
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { BackstageIdentityResponse } from './types';
|
||||
import { Request } from 'express';
|
||||
|
||||
/**
|
||||
* An identity client api to authenticate Backstage
|
||||
@@ -28,5 +29,7 @@ export interface IdentityApi {
|
||||
* Returns a BackstageIdentity (user) matching the token.
|
||||
* The method throws an error if verification fails.
|
||||
*/
|
||||
getIdentity(req: Request): Promise<BackstageIdentityResponse | undefined>;
|
||||
getIdentity(
|
||||
req: Request<any>,
|
||||
): Promise<BackstageIdentityResponse | undefined>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user