1
0
mirror of https://github.com/sasjs/core.git synced 2026-01-03 23:50:06 +00:00

fix: adding authentication to server macros. Closes #221

This commit is contained in:
Allan Bowe
2022-04-20 15:41:36 +00:00
parent c4cb0b2395
commit 11da53f1cb
7 changed files with 82 additions and 26 deletions

View File

@@ -61,8 +61,11 @@ data _null_;
run;
data _null_;
file &fname1;
file &fname1 lrecl=1000;
infile "&_sasjs_tokenfile" lrecl=1000;
input;
put "Content-Type: multipart/form-data; boundary=&boundary";
put "Authorization: Bearer " _infile_;
run;
%if &mdebug=1 %then %do;

View File

@@ -17,6 +17,8 @@
@param [in] driveloc The full path to the file in SASjs Drive
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
<h4> SAS Macros </h4>
@li mf_getuniquefileref.sas
**/
@@ -24,12 +26,23 @@
,mdebug=0
);
proc http method='DELETE'
%local headref;
%let headref=%mf_getuniquefileref();
data _null_;
file &headref lrecl=1000;
infile "&_sasjs_tokenfile" lrecl=1000;
input;
put "Authorization: Bearer " _infile_;
run;
proc http method='DELETE' headerin=&headref
url="&_sasjs_apiserverurl/SASjsApi/drive/file?_filePath=&driveloc";
%if &mdebug=1 %then %do;
debug level=2;
%end;
run;
filename &headref clear;
%mend ms_deletefile;

View File

@@ -5,7 +5,7 @@
Example:
%ms_getfile(/some/stored/file.ext, outref=myfile)
%ms_getfile(/Public/app/dc/services/public/settings.sas, outref=myfile)
@param [in] driveloc The full path to the file in SASjs Drive
@param [out] outref= (msgetfil) The fileref to contain the file.
@@ -23,13 +23,21 @@
);
/* use the recfm in a separate fileref to avoid issues with subsequent reads */
%local binaryfref floc;
%local binaryfref floc headref;
%let binaryfref=%mf_getuniquefileref();
%let headref=%mf_getuniquefileref();
%let floc=%sysfunc(pathname(work))/%mf_getuniquename().txt;
filename &outref "&floc";
filename &outref "&floc" lrecl=32767;
filename &binaryfref "&floc" recfm=n;
proc http method='GET' out=&binaryfref
data _null_;
file &headref lrecl=1000;
infile "&_sasjs_tokenfile" lrecl=1000;
input;
put "Authorization: Bearer " _infile_;
run;
proc http method='GET' out=&binaryfref headerin=&headref
url="&_sasjs_apiserverurl/SASjsApi/drive/file?_filePath=&driveloc";
%if &mdebug=1 %then %do;
debug level=2;
@@ -37,5 +45,6 @@ proc http method='GET' out=&binaryfref
run;
filename &binaryfref clear;
filename &headref clear;
%mend ms_getfile;
%mend ms_getfile;

View File

@@ -43,10 +43,10 @@
)
data _null_;
file &fname1;
infile "&_sasjs_tokenfile";
file &fname1 lrecl=1000;
infile "&_sasjs_tokenfile" lrecl=1000;
input;
put 'Authorization: Bearer' _infile_;
put 'Authorization: Bearer ' _infile_;
run;
filename &outref temp;