Skip to content

Commit

Permalink
[backend] only kill session in sseMiddleware for auth bearer sessions (
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremyCloarec authored Jan 27, 2025
1 parent f4fb41d commit 7ed76c1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion opencti-platform/opencti-graphql/src/domain/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ import { cleanMarkings } from '../utils/markingDefinition-utils';

const BEARER = 'Bearer ';
const BASIC = 'Basic ';
const AUTH_BEARER = 'Bearer';
export const AUTH_BEARER = 'Bearer';
const AUTH_BASIC = 'BasicAuth';
export const TAXIIAPI = 'TAXIIAPI';
const PLATFORM_ORGANIZATION = 'settings_platform_organization';
Expand Down
5 changes: 3 additions & 2 deletions opencti-platform/opencti-graphql/src/graphql/sseMiddleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as jsonpatch from 'fast-json-patch';
import { Promise } from 'bluebird';
import { LRUCache } from 'lru-cache';
import conf, { basePath, logApp } from '../config/conf';
import { authenticateUserFromRequest, TAXIIAPI } from '../domain/user';
import { AUTH_BEARER, authenticateUserFromRequest, TAXIIAPI } from '../domain/user';
import { createStreamProcessor, EVENT_CURRENT_VERSION } from '../database/redis';
import { generateInternalId } from '../schema/identifier';
import { stixLoadById, storeLoadByIdsWithRefs } from '../database/middleware';
Expand Down Expand Up @@ -63,7 +63,8 @@ const HEARTBEAT_PERIOD = conf.get('app:live_stream:heartbeat_period') ?? 5000;
const sendErrorStatusAndKillSession = (req, res, httpStatus) => {
try {
res.status(httpStatus).end();
if (req.session) {
// only kill bearer sessions
if (req.session && req.session?.session_provider?.provider === AUTH_BEARER) {
req.session.destroy();
}
} catch (error) {
Expand Down

0 comments on commit 7ed76c1

Please sign in to comment.