addressing some code review comments

Signed-off-by: Brian Fletcher <brian@roadie.io>
This commit is contained in:
Brian Fletcher
2022-08-15 14:34:26 +01:00
parent 7ab1fc429a
commit 518e5ddcd1
8 changed files with 52 additions and 16 deletions
+2 -5
View File
@@ -4,7 +4,6 @@
```ts
import { PluginEndpointDiscovery } from '@backstage/backend-common';
import { Request as Request_2 } from 'express';
// @public
export interface BackstageIdentityResponse extends BackstageSignInResult {
@@ -29,7 +28,7 @@ export class DefaultIdentityClient implements IdentityApi {
authenticate(token: string | undefined): Promise<BackstageIdentityResponse>;
static create(options: IdentityClientOptions): DefaultIdentityClient;
// (undocumented)
getIdentity(req: Request_2): Promise<BackstageIdentityResponse | undefined>;
getIdentity(req: Request): Promise<BackstageIdentityResponse | undefined>;
}
// @public
@@ -39,9 +38,7 @@ export function getBearerTokenFromAuthorizationHeader(
// @public
export interface IdentityApi {
getIdentity(
req: Request_2<any>,
): Promise<BackstageIdentityResponse | undefined>;
getIdentity(req: Request): Promise<BackstageIdentityResponse | undefined>;
}
// @public @deprecated
-2
View File
@@ -26,8 +26,6 @@
"@backstage/backend-common": "^0.15.0-next.0",
"@backstage/config": "^1.0.1",
"@backstage/errors": "^1.1.0",
"@types/express": "^4.17.6",
"express": "^4.18.1",
"jose": "^4.6.0",
"node-fetch": "^2.6.7",
"winston": "^3.2.1"
@@ -27,7 +27,6 @@ import { GetKeyFunction } from 'jose/dist/types/types';
import { BackstageIdentityResponse } from './types';
import { getBearerTokenFromAuthorizationHeader, IdentityApi } from '.';
import { Request } from 'express';
const CLOCK_MARGIN_S = 10;
@@ -78,7 +77,7 @@ export class DefaultIdentityClient implements IdentityApi {
async getIdentity(req: Request) {
try {
return await this.authenticate(
getBearerTokenFromAuthorizationHeader(req.headers.authorization),
getBearerTokenFromAuthorizationHeader(req.headers.get('authorization')),
);
} catch (e) {
return undefined;
+1 -4
View File
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Request } from 'express';
import { BackstageIdentityResponse } from './types';
/**
@@ -29,7 +28,5 @@ export interface IdentityApi {
* Returns a BackstageIdentity (user) matching the token.
* The method throws an error if verification fails.
*/
getIdentity(
req: Request<any>,
): Promise<BackstageIdentityResponse | undefined>;
getIdentity(req: Request): Promise<BackstageIdentityResponse | undefined>;
}