File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import Mirador from 'mirador/dist/es/src/index' ;
2+ import jwtDecode from "jwt-decode" ;
3+
24
35// You can modify this default Mirador configuration file. However,
46// you should consider creating a copy of this file named
@@ -85,7 +87,11 @@ windowSettings.manifestId = manifest;
8587 const authCookie = decodeURIComponent ( value ) ;
8688 const parsedCookie = JSON . parse ( authCookie ) ;
8789 if ( parsedCookie && parsedCookie [ tokenName ] ) {
88- return `Bearer ${ parsedCookie [ tokenName ] } ` ;
90+ const decodedJwt = jwtDecode ( parsedCookie [ tokenName ] ) ;
91+ const jwtExpDate = decodedJwt . exp * 1000 ;
92+ const isExpired = jwtExpDate <= Date . now ( ) ;
93+ // if token is expired we don't use it as it would cause a 403
94+ return isExpired ? null : `Bearer ${ parsedCookie [ tokenName ] } ` ;
8995 }
9096 }
9197 }
You can’t perform that action at this time.
0 commit comments