fix(events,github): fixes signature validation by using raw req body
Adds raw body information (body as buffer, encoding) to `RequestDetails` to support more request validation use cases. Additionally, uses the raw body to retrieve the transmitted JSON string unparsed/raw to correctly validate the signature. Previously, we re-stringified the parsed JSON payload which could lead to different JSON strings. Those differences can lead to the rejection of requests due to a mismatch in expected signature. Fixes: #26709 Relates-to: PR #26884 Co-authored-by: Christopher Diaz <cdiaz@rvohealth.com> Signed-off-by: Patrick Jungermann <Patrick.Jungermann@gmail.com>
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
||||
|
||||
```ts
|
||||
/// <reference types="node" />
|
||||
|
||||
import { AuthService } from '@backstage/backend-plugin-api';
|
||||
import { DiscoveryService } from '@backstage/backend-plugin-api';
|
||||
import { LifecycleService } from '@backstage/backend-plugin-api';
|
||||
@@ -114,10 +116,14 @@ export interface HttpPostIngressOptions {
|
||||
validator?: RequestValidator;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
// @public
|
||||
export interface RequestDetails {
|
||||
body: unknown;
|
||||
headers: Record<string, string | string[] | undefined>;
|
||||
raw: {
|
||||
body: Buffer;
|
||||
encoding: BufferEncoding;
|
||||
};
|
||||
}
|
||||
|
||||
// @public
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* View on an incoming request that has to be validated.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface RequestDetails {
|
||||
@@ -26,4 +28,18 @@ export interface RequestDetails {
|
||||
* Key-value pairs of header names and values. Header names are lower-cased.
|
||||
*/
|
||||
headers: Record<string, string | string[] | undefined>;
|
||||
/**
|
||||
* Raw request details.
|
||||
*/
|
||||
raw: {
|
||||
/**
|
||||
* Raw request body (buffer).
|
||||
*/
|
||||
body: Buffer;
|
||||
/**
|
||||
* Encoding of the raw request body.
|
||||
* Can be used to decode the raw request body like `raw.body.toString(raw.encoding)`.
|
||||
*/
|
||||
encoding: BufferEncoding;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user