🔐 OIDC back-channel logout (#521)

* feat: oidc backchannel session storage
* feat: oidc backchannel logout
* ref: e2e test
* 🛠️ Code review
* ♻️ Do not mock internal auth token but call "/login" with oidc_token instead
* ♻️ Refactoring for back-channel logout test
* fix: feedback and e2e tests
* feat: more e2e tests
* ♻️ Added test to test multiple login requests flow
* ref: jwt sid verifier and e2e tests

---------

Co-authored-by: Monta <monta@HP-ProBook-445-14-inch-G9-Notebook-PC-505aadfc.localdomain>
Co-authored-by: Anton SHEPILOV <ashepilov@linagora.com>
This commit is contained in:
Montassar Ghanmy
2024-05-24 12:52:58 +01:00
committed by GitHub
parent c8a9145906
commit b4412d3ed3
22 changed files with 426 additions and 22 deletions
@@ -7,6 +7,7 @@ import Workspace, {
getInstance as getWorkspaceInstance,
WorkspacePrimaryKey,
} from "./../../src/services/workspaces/entities/workspace";
import Session from "../../src/services/console/entities/session";
import { v1 as uuidv1 } from "uuid";
import CompanyUser from "../../src/services/user/entities/company_user";
@@ -161,9 +162,9 @@ export class TestDbService {
this.users.push(createdUser);
if (workspacesPk && workspacesPk.length) {
await gr.services.companies.setUserRole(
this.company ? this.company.id : workspacesPk[0].company_id,
createdUser.id,
options.companyRole ? options.companyRole : "member",
this.company ? this.company.id : workspacesPk[0].company_id,
createdUser.id,
options.companyRole ? options.companyRole : "member",
);
}
@@ -255,8 +256,27 @@ export class TestDbService {
return this;
}
async createSession(sid: string, sub: string): Promise<Session> {
const session = new Session();
session.sid = sid;
session.sub = sub;
const sessionRepository = await this.database.getRepository<Session>("session", Session);
await sessionRepository.save(session);
return session;
}
async getSessionById(sid: string): Promise<Session> {
const sessionRepository = await this.database.getRepository<Session>("session", Session);
return sessionRepository.findOne({ sid });
}
async getSessionsByUserId(sub: string): Promise<Session[]> {
const sessionRepository = await this.database.getRepository<Session>("session", Session);
return (await sessionRepository.find({ sub })).getEntities();
}
async cleanUp() {
await this.database.getConnector().drop()
await this.database.getConnector().drop();
}
getRepository = (type, entity) => {