Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[backend] only kill session in sseMiddleware for auth bearer sessions (#9216) #9708

Merged
merged 1 commit into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 { 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';

Check warning on line 6 in opencti-platform/opencti-graphql/src/graphql/sseMiddleware.js

View check run for this annotation

Codecov / codecov/patch

opencti-platform/opencti-graphql/src/graphql/sseMiddleware.js#L6

Added line #L6 was not covered by tests
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 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) {

Check warning on line 67 in opencti-platform/opencti-graphql/src/graphql/sseMiddleware.js

View check run for this annotation

Codecov / codecov/patch

opencti-platform/opencti-graphql/src/graphql/sseMiddleware.js#L66-L67

Added lines #L66 - L67 were not covered by tests
req.session.destroy();
}
} catch (error) {
Expand Down
Loading