File tree Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ class TestAuthJWT {
76
76
const encoded = await sign ( { } , keypair . privateKey , {
77
77
algorithm : "RS512" ,
78
78
expiresIn : "1d" ,
79
- issuer : this . config . hostUrl . toStringWoRootSlash ( ) ,
79
+ issuer : "https://mp-server-d7650ec945.preview.gitpod-dev.com" ,
80
80
keyid : keypair . id ,
81
81
subject,
82
82
} ) ;
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ export function registerServerMetrics(registry: prometheusClient.Registry) {
26
26
registry . registerMetric ( spicedbClientLatency ) ;
27
27
registry . registerMetric ( dashboardErrorBoundary ) ;
28
28
registry . registerMetric ( jwtCookieIssued ) ;
29
+ registry . registerMetric ( sessionsWithJWTs ) ;
29
30
}
30
31
31
32
const loginCounter = new prometheusClient . Counter ( {
@@ -67,6 +68,16 @@ export function reportJWTCookieIssued() {
67
68
jwtCookieIssued . inc ( ) ;
68
69
}
69
70
71
+ const sessionsWithJWTs = new prometheusClient . Counter ( {
72
+ name : "gitpod_server_sessions_with_jwts_total" ,
73
+ help : "Total number of sessions which did/or did not contain JWTs" ,
74
+ labelNames : [ "present" ] ,
75
+ } ) ;
76
+
77
+ export function reportSessionHasJWT ( jwtPresent : boolean ) {
78
+ sessionsWithJWTs . inc ( { present : `${ jwtPresent } ` } ) ;
79
+ }
80
+
70
81
const apiConnectionClosedCounter = new prometheusClient . Counter ( {
71
82
name : "gitpod_server_api_connections_closed_total" ,
72
83
help : "Total amount of closed API connections" ,
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import { log } from "@gitpod/gitpod-protocol/lib/util/logging";
16
16
import { Config as DBConfig } from "@gitpod/gitpod-db/lib/config" ;
17
17
import { Config } from "./config" ;
18
18
import { GitpodHostUrl } from "@gitpod/gitpod-protocol/lib/util/gitpod-host-url" ;
19
+ import { reportSessionHasJWT } from "./prometheus-metrics" ;
19
20
20
21
@injectable ( )
21
22
export class SessionHandlerProvider {
@@ -40,7 +41,14 @@ export class SessionHandlerProvider {
40
41
41
42
options . store = this . createStore ( ) ;
42
43
43
- this . sessionHandler = session ( options ) ;
44
+ this . sessionHandler = ( req : express . Request , res : express . Response , next : express . NextFunction ) => {
45
+ const jwt = req . cookies [ SessionHandlerProvider . getJWTCookieName ( this . config . hostUrl ) ] ;
46
+ const containedJWT = ! ! jwt ;
47
+
48
+ reportSessionHasJWT ( containedJWT ) ;
49
+
50
+ return session ( options ) ( req , res , next ) ;
51
+ } ;
44
52
}
45
53
46
54
protected getCookieOptions ( config : Config ) : express . CookieOptions {
You can’t perform that action at this time.
0 commit comments