mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Implement DiscourseConnect to enable easy sign-in to community forum
Summary: - Update cookie module, to support modern sameSite settings - Add a new cookie, grist_sid_status with less-sensitive value, to let less-trusted subdomains know if user is signed in - The new cookie is kept in-sync with the session cookie. - For a user signed in once, allow auto-signin is appropriate. - For a user signed in with multiple accounts, show a page to select which account to use. - Move css stylings for rendering users to a separate module. Test Plan: Added a test case with a simulated Discourse page to test redirects and account-selection page. Reviewers: paulfitz Reviewed By: paulfitz Differential Revision: https://phab.getgrist.com/D3047
This commit is contained in:
@@ -2,9 +2,11 @@ import * as net from 'net';
|
||||
|
||||
import {UserProfile} from 'app/common/LoginSessionAPI';
|
||||
import {Deps as ActiveDocDeps} from 'app/server/lib/ActiveDoc';
|
||||
import {Deps as DiscourseConnectDeps} from 'app/server/lib/DiscourseConnect';
|
||||
import * as Comm from 'app/server/lib/Comm';
|
||||
import * as log from 'app/server/lib/log';
|
||||
import {IMessage, Rpc} from 'grain-rpc';
|
||||
import {Request} from 'express';
|
||||
import * as t from 'ts-interface-checker';
|
||||
import {FlexServer} from './FlexServer';
|
||||
import {ITestingHooks} from './ITestingHooks';
|
||||
@@ -74,7 +76,8 @@ export class TestingHooks implements ITestingHooks {
|
||||
log.info("TestingHooks.setLoginSessionProfile called with", gristSidCookie, profile, org);
|
||||
const sessionId = this._comm.getSessionIdFromCookie(gristSidCookie);
|
||||
const scopedSession = this._comm.getOrCreateSession(sessionId, {org});
|
||||
return await scopedSession.updateUserProfile(profile);
|
||||
const req = {} as Request;
|
||||
return await scopedSession.updateUserProfile(req, profile);
|
||||
}
|
||||
|
||||
public async setServerVersion(version: string|null): Promise<void> {
|
||||
@@ -180,4 +183,15 @@ export class TestingHooks implements ITestingHooks {
|
||||
return prev;
|
||||
}
|
||||
|
||||
// Sets env vars for the DiscourseConnect module, and returns the previous value.
|
||||
public async setDiscourseConnectVar(varName: string, value: string|null): Promise<string|null> {
|
||||
const key = varName as keyof typeof DiscourseConnectDeps;
|
||||
const prev = DiscourseConnectDeps[key] || null;
|
||||
if (value == null) {
|
||||
delete DiscourseConnectDeps[key];
|
||||
} else {
|
||||
DiscourseConnectDeps[key] = value;
|
||||
}
|
||||
return prev;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user