@@ -3,7 +3,7 @@ import http from 'http';
3
3
import https from 'https' ;
4
4
import { readFileSync } from 'fs' ;
5
5
import express from 'express' ;
6
- import jwt from 'express-jwt' ;
6
+ import { expressjwt as jwt } from 'express-jwt' ;
7
7
import cors from 'cors' ;
8
8
import * as db from './db.mjs' ;
9
9
import { pick , sleep , git_sha , svg_width } from './util.mjs' ;
@@ -66,14 +66,14 @@ function require_sub(...subs) {
66
66
// pass if auth is disabled or no subjects are required
67
67
if ( CONFIG . auth . enabled === false || subs . length == 0 ) { next ( ) ; return ; }
68
68
// check if token subject is one of the required subjects
69
- // console.log('got sub:', req.user .sub);
70
- if ( ! subs . includes ( req . user . sub ) ) {
69
+ // console.log('got sub:', req.auth .sub);
70
+ if ( ! subs . includes ( req . auth . sub ) ) {
71
71
res . status ( 403 ) . json ( { 'error' : 'wrong subject' } ) ;
72
72
return ;
73
73
}
74
74
// check if subject isn't expired (issued at or after latest issue date for the role)
75
75
// doesn't apply if no issued_at is defined for a subject
76
- if ( req . user . iat < CONFIG . auth . subject_issued_at [ req . user . sub ] ) {
76
+ if ( req . auth . iat < CONFIG . auth . subject_issued_at [ req . auth . sub ] ) {
77
77
res . status ( 403 ) . json ( { 'error' : 'subject expired' } ) ;
78
78
return ;
79
79
}
0 commit comments