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:
Brian Fletcher
2022-08-16 11:58:59 +01:00
parent c7e6c23c38
commit 90223b820b
4 changed files with 12 additions and 4 deletions
+5 -2
View File
@@ -4,6 +4,7 @@
```ts
import { PluginEndpointDiscovery } from '@backstage/backend-common';
import { Request as Request_2 } from 'express';
// @public
export interface BackstageIdentityResponse extends BackstageSignInResult {
@@ -28,7 +29,7 @@ export class DefaultIdentityClient implements IdentityApi {
authenticate(token: string | undefined): Promise<BackstageIdentityResponse>;
static create(options: IdentityClientOptions): DefaultIdentityClient;
// (undocumented)
getIdentity(req: Request): Promise<BackstageIdentityResponse | undefined>;
getIdentity(req: Request_2): Promise<BackstageIdentityResponse | undefined>;
}
// @public
@@ -38,7 +39,9 @@ export function getBearerTokenFromAuthorizationHeader(
// @public
export interface IdentityApi {
getIdentity(req: Request): Promise<BackstageIdentityResponse | undefined>;
getIdentity(
req: Request_2<any>,
): Promise<BackstageIdentityResponse | undefined>;
}
// @public @deprecated
+1
View File
@@ -26,6 +26,7 @@
"@backstage/backend-common": "^0.15.0-next.0",
"@backstage/config": "^1.0.1",
"@backstage/errors": "^1.1.0",
"express": "^4.17.13",
"jose": "^4.6.0",
"node-fetch": "^2.6.7",
"winston": "^3.2.1"
@@ -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;
+4 -1
View File
@@ -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>;
}