I need to extract username and password for user authentication.
As suggested I tried adding ReqHeader to the Service_Interface code, but when I tried to map the HTTP GET once more
I am getting the following error:
Rest file include Invocation file generation failed. The procedure includes unsupported data types "openedge.net.http.httpheader". Remove the unsupported parameter data types from the following procedures(s):
"Read1" to successfully generate REST invocation file.
Any ideas on how to recover the userid/password from the request header since I am sending it to the OEPAS instance ?
/* Code from Service_Interface
block-level on error undo, throw.
using Progress.Lang.*.
/* *************************** Definitions ************************** */
define variable CustInfoInstanceRead as AppServer.CustomerDispatcher no-undo.
define input parameter CustId as integer no-undo.
define input parameter ReqHeader as OpenEdge.Net.HTTP.HttpHeader no-undo.
define temp-table custrecord like Customer.
define output parameter TABLE for custrecord.
define output parameter reason as character no-undo.
CustInfoInstanceRead= new AppServer.CustomerDispatcher().
CustInfoInstanceRead:Read1(input CustId,input ReqHeader,output TABLE custrecord,output reason).
return.
---------------------------------------------------------------------------------------------------------------
/* Snippet from CustomerDispatcher Class */
@openapi.openedge.export(type="REST", useReturnValue="false", writeDataSetBeforeImage="false").
method public integer Read1(input custId as integer, input ReqHeader as OpenEdge.Net.HTTP.HttpHeader, output TABLE custRecord, output httpReason as character):
define variable httpStatus as integer initial 200.
/* Assume 200 status code */
empty temp-table custRecord.
find first Customer where Customer.CustNum = custId no-error.
if available Customer then do:
create custRecord.
buffer-copy Customer to custRecord.
end.
else do:
httpStatus = 404.
httpReason = "ERROR: Customer " + STRING(custId) + " not found]".
end.
release Customer.
return httpStatus.
end method.
|
We do this by mapping the Authorization header, then we get the value through an CHARACTER input parameter.
Using Basic authentification scheme, the first entry (separated by " ") must be "Basic" and the second one is a base64 encoded string that you must pass through base64-decode in order to get the string "user:password".
Thank for you response. No sure I am doing this correctly. I tried to select 'Authorization' under the input "Headers" tag of the URI editor, but only 'Content-Type' was available to choose from once I click and selected the 'Add Node'.option.
I am aware of the need to base64-decode, the base64 encoded once I retrieve it, but my show stopper is how to get to that string...