mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
[authorizer] Determine auth header to use via an environment variable
This commit is contained in:
parent
c459037b04
commit
9f3ed989c4
@ -92,16 +92,14 @@ export function isSingleUserMode(): boolean {
|
||||
|
||||
/**
|
||||
* Returns a profile if it can be deduced from the request. This requires a
|
||||
* header to specify the users' email address.
|
||||
* header to specify the users' email address. The header to set comes from the
|
||||
* environment variable GRIST_PROXY_AUTH_HEADER.
|
||||
*/
|
||||
export function getRequestProfile(req: Request): UserProfile|undefined {
|
||||
// Try to determine user based on 'x-remote-user' header passed via a webserver rewrite rule.
|
||||
// TODO: The header should probably be set via an environment variable and if it is not set,
|
||||
// this code path should be disabled altogether.
|
||||
let header:string = "x-remote-user";
|
||||
const header = process.env.GRIST_PROXY_AUTH_HEADER;
|
||||
let profile: UserProfile|undefined;
|
||||
|
||||
if (req.headers && req.headers[header]) {
|
||||
if (header && req.headers && req.headers[header]) {
|
||||
let headerContent = req.headers[header];
|
||||
if (headerContent) {
|
||||
const userEmail = headerContent.toString();
|
||||
|
Loading…
Reference in New Issue
Block a user