File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,11 +19,29 @@ class Vault {
1919 return ;
2020 }
2121
22- const reqCtx = JSON . parse ( query . requestContext ) ;
23- if ( reqCtx . headers [ 'x-amz-security-token' ] && ! query . securityToken ) {
24- res . writeHead ( 400 , { 'Content-Type' : 'application/json' } ) ;
25- res . write ( JSON . stringify ( { code : 'InvalidSecurityToken' , message : 'Security token is missing' } ) ) ;
26- res . end ( ) ;
22+ if ( req . method == 'GET' ) {
23+ const reqCtx = JSON . parse ( query . requestContext ) ;
24+ if ( reqCtx . headers [ 'x-amz-security-token' ] && ! query . securityToken ) {
25+ res . writeHead ( 400 , { 'Content-Type' : 'application/json' } ) ;
26+ res . write ( JSON . stringify ( { code : 'InvalidSecurityToken' , message : 'Security token is missing' } ) ) ;
27+ res . end ( ) ;
28+ return ;
29+ }
30+ } else if ( req . method == 'POST' ) {
31+ const body = [ ] ;
32+ req . on ( 'data' , chunk => {
33+ body . push ( chunk ) ;
34+ } ) ;
35+ req . on ( 'end' , ( ) => {
36+ const bodyString = Buffer . concat ( body ) . toString ( ) ;
37+ const bodyJson = JSON . parse ( bodyString ) ;
38+ if ( bodyJson . requestContext . headers [ 'x-amz-security-token' ] && ! query . securityToken ) {
39+ res . writeHead ( 400 , { 'Content-Type' : 'application/json' } ) ;
40+ res . write ( JSON . stringify ( { code : 'InvalidSecurityToken' , message : 'Security token is missing' } ) ) ;
41+ res . end ( ) ;
42+ return ;
43+ }
44+ } ) ;
2745 return ;
2846 }
2947
You can’t perform that action at this time.
0 commit comments