mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Fixing origin check during Google Authentication
Summary: Fixing two bugs - Google Auth Endpoint wasn't resolving protocol in a correct way - Google Auth Popup was navigationg to endpoint url based on home url, which was diffent from current page origin Test Plan: n/a Reviewers: paulfitz Reviewed By: paulfitz Subscribers: paulfitz Differential Revision: https://phab.getgrist.com/D2937
This commit is contained in:
@@ -237,3 +237,16 @@ export function optIntegerParam(p: any): number|undefined {
|
||||
export interface RequestWithGristInfo extends Request {
|
||||
gristInfo?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns original request origin. In case, when a client was connected to proxy
|
||||
* or load balancer, it reads protocol from forwarded headers.
|
||||
* More can be read on:
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Proto
|
||||
* https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/x-forwarded-headers.html
|
||||
*/
|
||||
export function getOriginUrl(req: Request) {
|
||||
const host = req.headers.host!;
|
||||
const protocol = req.get("X-Forwarded-Proto") || req.protocol;
|
||||
return `${protocol}://${host}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user