File tree Expand file tree Collapse file tree 3 files changed +30
-1
lines changed Expand file tree Collapse file tree 3 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ var expressLogging = require("express-logging");
4
4
var queryString = require ( "querystring" ) ;
5
5
var path = require ( "path" ) ;
6
6
var conf = require ( "./config" ) ;
7
+ var jwtDecode = require ( "jwt-decode" )
7
8
8
9
function handleErr ( err , response ) {
9
10
response . statusCode = 500 ;
@@ -76,7 +77,17 @@ function createHandler(dir, static) {
76
77
} ;
77
78
78
79
var callback = createCallback ( response ) ;
79
- var promise = handler . handler ( lambdaRequest , { } , callback ) ;
80
+ let clientContext = { }
81
+ if ( request . headers [ 'authorization' ] ) {
82
+ const parts = request . headers [ 'authorization' ] . split ( ' ' )
83
+ if ( parts . length === 2 && parts [ 0 ] === 'Bearer' ) {
84
+ clientContext = {
85
+ identity : { url : '' , token : '' } ,
86
+ user : jwtDecode ( parts [ 1 ] )
87
+ }
88
+ }
89
+ }
90
+ var promise = handler . handler ( lambdaRequest , { clientContext } , callback ) ;
80
91
promiseCallback ( promise , callback ) ;
81
92
} ;
82
93
}
Original file line number Diff line number Diff line change 30
30
"commander" : " ^2.17.1" ,
31
31
"express" : " ^4.16.3" ,
32
32
"express-logging" : " ^1.1.1" ,
33
+ "jwt-decode" : " ^2.2.0" ,
33
34
"toml" : " ^2.3.3" ,
34
35
"webpack" : " ^4.17.1" ,
35
36
"webpack-merge" : " ^4.1.4"
Original file line number Diff line number Diff line change @@ -2040,6 +2040,23 @@ json5@^0.5.0:
2040
2040
version "0.5.1"
2041
2041
resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821"
2042
2042
2043
+ jsonify@~0.0.0 :
2044
+ version "0.0.0"
2045
+ resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73"
2046
+
2047
+ jsprim@^1.2.2 :
2048
+ version "1.4.1"
2049
+ resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.1.tgz#313e66bc1e5cc06e438bc1b7499c2e5c56acb6a2"
2050
+ dependencies :
2051
+ assert-plus "1.0.0"
2052
+ extsprintf "1.3.0"
2053
+ json-schema "0.2.3"
2054
+ verror "1.10.0"
2055
+
2056
+ jwt-decode@^2.2.0 :
2057
+ version "2.2.0"
2058
+ resolved "https://registry.yarnpkg.com/jwt-decode/-/jwt-decode-2.2.0.tgz#7d86bd56679f58ce6a84704a657dd392bba81a79"
2059
+
2043
2060
kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.2.0 :
2044
2061
version "3.2.2"
2045
2062
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64"
You can’t perform that action at this time.
0 commit comments