@@ -18,7 +18,7 @@ function s3app(params) {
1818 res . header ( 'Access-Control-Allow-Methods' ,
1919 'GET,POST,PUT,DELETE,OPTIONS' ) ;
2020 res . header ( 'Access-Control-Allow-Headers' ,
21- 'Content-Type,Authorization,X-Amz-User-Agent,X-Amz-Date,ETag' ) ;
21+ 'Content-Type,Authorization,X-Amz-User-Agent,X-Amz-Date,ETag,X-Amz-Content-Sha256 ' ) ;
2222 res . header ( 'Access-Control-Allow-Origin' , '*' ) ;
2323 res . header ( 'Access-Control-Expose-Headers' , 'ETag' ) ;
2424 // note that browsers will not allow origin=* with credentials
@@ -66,15 +66,16 @@ function s3app(params) {
6666 dbg . log0 ( 'authorization header exists' , req . headers . authorization ) ;
6767
6868 var end_of_aws_key = req . headers . authorization . indexOf ( ':' ) ;
69- var req_access_key = req . headers . authorization . substring ( 4 , end_of_aws_key ) ;
70- if ( req_access_key === 'AWS4' ) {
69+ var req_access_key ;
70+ if ( req . headers . authorization . substring ( 0 , 4 ) === 'AWS4' ) {
7171 //authorization: 'AWS4-HMAC-SHA256 Credential=wwwwwwwwwwwww123aaaa/20151023/us-east-1/s3/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=0b04a57def200559b3353551f95bce0712e378c703a97d58e13a6eef41a20877',
72-
73- var credentials_location = req . headers . authorization . indexOf ( 'Credential' ) + 11 ;
74-
72+ var credentials_location = req . headers . authorization . indexOf ( 'Credential' ) + 11 ;
7573 req_access_key = req . headers . authorization . substring ( credentials_location , req . headers . authorization . indexOf ( '/' ) ) ;
74+ } else {
75+ req_access_key = req . headers . authorization . substring ( 4 , end_of_aws_key ) ;
7676 }
77- dbg . log0 ( 'req_access_key' , req_access_key ) ;
77+
78+ dbg . log0 ( 'req_access_key' , req_access_key ) ;
7879
7980 req . access_key = req_access_key ;
8081 req . signature = req . headers . authorization . substring ( end_of_aws_key + 1 , req . headers . authorization . lenth ) ;
@@ -84,7 +85,14 @@ function s3app(params) {
8485 req . signature = req . query . Signature ;
8586 authenticated_request = true ;
8687 dbg . log0 ( 'signed url' ) ;
88+ } else if ( req . query [ 'X-Amz-Credential' ] ) {
89+ req . access_key = req . query [ 'X-Amz-Credential' ] . substring ( 0 , req . query [ 'X-Amz-Credential' ] . indexOf ( '/' ) ) ;
90+ req . signature = req . query [ 'X-Amz-Signature' ] ;
91+ authenticated_request = true ;
92+ dbg . log0 ( 'signed url v4' , req . access_key ) ;
93+
8794 }
95+
8896 if ( authenticated_request ) {
8997 // var s3 = new s3_auth(req);
9098 dbg . log0 ( 'authenticated request with signature' , req . signature ) ;
0 commit comments