Skip to content

Commit d4360ca

Browse files
authored
Merge pull request #1014 from constructive-io/feat/graphile-session-id-claim
feat(graphile): propagate jwt.claims.session_id to pgSettings
2 parents 15a46bc + 41ab24d commit d4360ca

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

graphql/server/src/middleware/graphile.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,10 @@ const buildPreset = (
239239
...context,
240240
};
241241

242+
if (req.token.session_id) {
243+
pgSettings['jwt.claims.session_id'] = req.token.session_id;
244+
}
245+
242246
// Propagate credential metadata as JWT claims so PG functions
243247
// can read them via current_setting('jwt.claims.access_level') etc.
244248
if (req.token.access_level) {

graphql/server/src/middleware/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { ApiStructure } from '../types';
33
export type ConstructiveAPIToken = {
44
id?: string;
55
user_id?: string;
6+
session_id?: string;
67
access_level?: string;
78
kind?: string;
89
[key: string]: unknown;

0 commit comments

Comments
 (0)