Changes for page Securing your SOAP Webservice
Last modified by Danniar Firdausy on 2024/09/05 14:24
From version 37.1
edited by Erik Bakker
on 2022/06/12 09:37
on 2022/06/12 09:37
Change comment:
There is no comment for this version
To version 41.1
edited by Erik Bakker
on 2023/01/23 08:29
on 2023/01/23 08:29
Change comment:
There is no comment for this version
Summary
-
Page properties (2 modified, 0 added, 0 removed)
Details
- Page properties
-
- Title
-
... ... @@ -1,1 +1,1 @@ 1 -SOAP Headers1 +Securing your SOAP Webservice - Content
-
... ... @@ -1,62 +1,103 @@ 1 1 {{container}}{{container layoutStyle="columns"}}((( 2 -When communicatingviaSOAPwebservicecallsit canhappenthatanexchangeofdataneedsto happenbetweenthemessageheadersonyourmessage and theSOAPheaders. In this microlearning, we willlearn aboutthis exchangeinbothdirections.SOAP Headersareheaders withinaSOAP Envelopethatcan beused to communicatemetadataor authenticationinformationbetweenparties.2 +When setting up a point at which your customers can talk to you eMagiz offers various methods of creating such a point. One of those options is by hosting a SOAP Webservice in eMagiz that handles XML messages asynchronously or synchronously. In this microlearning, we will zoom in on the part that security plays on a client level when hosting a SOAP web service. 3 3 4 4 Should you have any questions, please contact academy@emagiz.com. 5 5 6 -* Last update: June 10th, 2021 7 -* Required reading time: 5 minutes 8 - 9 9 == 1. Prerequisites == 10 10 * Basic knowledge of the eMagiz platform 11 11 12 12 == 2. Key concepts == 13 -This microlearning centers around SOAP Headers.10 +This microlearning centers around configuring your SOAP web service. 14 14 15 -By SOAP Headers, we mean:headerswithin aSOAP Envelope that can be used to communicatemetadata oruthenticationinformationbetweenparties12 +By configuring, we mean: Designing and determining the characteristics of the SOAP web service 16 16 17 -You can exchange data from: 18 -* SOAP Header to Message Header 19 -* Message Header to SOAP Header 14 +Crucial parts in the configuration are: 15 +* Operation Name 16 +* SOAP Webservice Namespace 17 +* Validation 18 +* Authentication 20 20 21 -In both cases ensure that the correct information is exchanged. 22 - 23 -== 3. SOAP Headers == 20 +Of these four points, we will zoom in on the authentication part of our SOAP Webservice in this microlearning. 24 24 25 - WhencommunicatingviaSOAP web service calls it canhappen that an exchangeof data needs to happen between the message headers onyourmessage and theSOAPheaders. In this microlearning, we will learn about thisxchange in both directions. SOAP Headers are headers within a SOAP Envelope that can be used to communicatemetadata or authentication information between parties.22 +== 3. Securing your SOAP Webservice == 26 26 27 -You can exchange data from: 28 -* SOAP Header to Message Header 29 -* Message Header to SOAP Header 24 +When setting up a point at which your customers can talk to you eMagiz offers various methods of creating such a point. One of those options is by hosting a SOAP Webservice in eMagiz that handles XML messages asynchronously or synchronously. In this microlearning, we will zoom in on the part that security plays on a client level when hosting a SOAP web service. 30 30 31 -In both cases ensure that the correct information is exchanged. 26 +Crucial parts in the configuration are: 27 +* Operation Name 28 +* SOAP Webservice Namespace 29 +* Validation 30 +* Authentication 32 32 33 - Ina previousmicrolearning, wealreadydiscussedone aspectfthis.Asyouprobablyrecallfromourmicrolearningon[Securing your SOAPWebservice](novice-soap-web service-connectivity-securing-your-soap-webservice.md)weneededtoexchangedatabetween theSOAPheaderthatourclient was sendingand a messageheaderthemessagesowe couldcheck whetheror nottheclientwas authorizedtocalltheoperation.32 +Of these four points, we will zoom in on the authentication part of our SOAP Webservice in this microlearning. When hosting your SOAP web service in the eMagiz Cloud the endpoint will be HTTPS secured on default. If you want to mimic the same result for an on-premise environment you should define the valid SSL settings, as explained in this [[Q&A>>https://my.emagiz.com/p/question/172825635700357186||target="blank"]]. 34 34 35 - Inthatmicrolearning, we also discussedtheomponent thatweneedforthis.The'complexSOAPheadermapper'.34 +Apart from that aspect of security, we should also consider how clients that call the SOAP Web service will authenticate themselves upon entry. Within eMagiz, we advise a two-step approach. Each client that wants to call your SOAP Webservice should: 36 36 37 -[[image:Main.Images.Microlearning.WebHome@novice-soap-webservice-connectivity-soap-headers--complex-soap-header-mapper.png]] 36 +* Send along a client certificate 37 +* Send along an API key in a SOAP Header that references to the word apiKey (i.e. apiKey) 38 38 39 - Asyoucanseeyoucanmapfromandtomessageheaderswith regardsotheSOAPHeaders.As wealreadydiscussedthefirst scenarioinanearlier microlearningI willfor now continuewiththeotherscenario.Thisscenario is mainlyneeded wheneMagizcallsa SOAPweb service thatis hostedby anexternalparty. Sincewe wouldormallydo thisn exit(gate/flow) let usopen such an exit ineMagizandnter"StartEditing"mode.39 +To verify both parts some configuration is needed. The first aspect, checking for a valid client certificate is done on cloud level. For more information on how to exactly configure this please take a look at the microlearning [Securing a hosted web service with certificates in the eMagiz Cloud](intermediate-securing-your-data-traffic-securing-a-hosted-webservice-with-certificates-in-the-emagiz-cloud.md). 40 40 41 - The first step weneedto take is to ensure that theinformation that we need tosendto the SOAP web service in question (in this a unique reference number)is available in a message header. Thiscan be done by verifying in all steps that preceded before the message entered the exit whether ornot this piece of information was already added to a message header. In this case, weassume that thisis the case since we want tofocus on the'complex SOAP header mapper' component and itsrelation to the web servicesoutboundgateway. To correctlyexchange data from a message header to a SOAP header we need to definea valid SpEL expression. Seethehelp text of thecomponentfor a suggestion of what a valid SpEL expression is. The key part in this is knowinghow the external party wants to receive the header(s) and how you(orone of your colleagues) has namedthe message header. When you have those twoinformationelements you can write the correct expression.The result should be something as follows:41 +In this microlearning, we will focus on the second part of the configuration. 42 42 43 - [[image:Main.Images.Microlearning.WebHome@novice-soap-webservice-connectivity-soap-headers--mapping-from-message-header.png]]43 +=== 3.1 API Key verification === 44 44 45 - Once youaresatisfiedyoucanpressSaveandlinkthesupportbject to thewebservice outboundgateway.45 +To verify whether the client has sent a valid API Key we need to change the configuration within the entry flow in the Create phase of eMagiz. The configuration consists of three steps: 46 46 47 -With this information, you can place SOAP Headers on message headers and vice versa every time you need it. 47 +* Get value from SOAP Header 48 +* Check value against a list 49 +* Respond based on results 48 48 51 +==== 3.1.1 Get value from SOAP Header ==== 52 + 53 +Let us move to the entry flow by going to the Create phase of eMagiz, opening the correct flow, and entering "Start Editing" mode. After you have done so we need to add a support object to the flow. The support we need is called 'Complex SOAP header mapper'. In this component, we need the bottom section. 54 + 55 +[[image:Main.Images.Microlearning.WebHome@novice-soap-webservice-connectivity-securing-your-soap-webservice--complex-soap-header-mapper.png]] 56 + 57 +Here we define a new header by entering a name and a valid XPath expression. 58 + 59 +[[image:Main.Images.Microlearning.WebHome@novice-soap-webservice-connectivity-securing-your-soap-webservice--complex-soap-header-mapper-config.png]] 60 + 61 +When you are satisfied you can press Save twice to store the support object. After we have configured the support object we need to link it to our web service inbound gateway. To do so open the component, navigate to the advanced tab and select the Header mapper you have just created. 62 + 63 +[[image:Main.Images.Microlearning.WebHome@novice-soap-webservice-connectivity-securing-your-soap-webservice--link-complex-soap-header-mapper.png]] 64 + 65 +==== 3.1.2 Check value against list ==== 66 + 67 +Now that we placed the value the client has entered in the apiKey SOAP header on our message we can check whether the value exists in a list of predefined valid values. To do add two headers to the standard header enricher component in your flow. The first one ensures that the apiKey is removed from the header (to prevent the API key from being publicly seen by others). The second one searches for the client name that corresponds with the apiKey and returns the name of the client in the header. This search action is done with the help of a SpEL expression, more on that later on. In this case the SpEL expression we use is set up as follows: 68 + 69 +{{code}}headers['spwbsrv_apiKey'] != null and {${authentication.api-keys}}.contains(headers.spwbsrv_apiKey) ? {${authentication.tenant-ids}}[{${authentication.api-keys}}.indexOf(headers.spwbsrv_apiKey)] : null{{/code}} 70 + 71 +With this SpEL expression, we check whether there is an API key and whether that apiKey can be found in a predefined list. If so we search for the corresponding name based on the index of where a certain apiKey is within the list. If not the header is not created. Combining this logic in one component should look similar to the following. 72 + 73 +[[image:Main.Images.Microlearning.WebHome@novice-soap-webservice-connectivity-securing-your-soap-webservice--check-headers.png]] 74 + 75 +==== 3.1.3 Respond based on results ==== 76 + 77 +After we have searched for the API key in the list and we have defined the client that is sending the information (or not) we can respond to the client whether or not the client is authorized to call our SOAP web service. To execute this check we first need a standard filter component. In this component, we will check whether the spwbsrv_client header we have just created is not null. 78 + 79 +[[image:Main.Images.Microlearning.WebHome@novice-soap-webservice-connectivity-securing-your-soap-webservice--standard-filter.png]] 80 + 81 +If it is indeed not null we can pass the empty message back to the client telling the client that the message was delivered successfully. If the header is null we need to tell the client that he/she is unauthorized to call the operation. To do so we need to add a component called 'custom error message activator'. In this component, we define the message we want to give back to the client in case of an error. In this case, we simply give back 'Unauthorized'. 82 + 83 +[[image:Main.Images.Microlearning.WebHome@novice-soap-webservice-connectivity-securing-your-soap-webservice--custom-error-message.png]] 84 + 85 +With all this done we have successfully secured our SOAP web service according to the best practices. 86 + 49 49 == 4. Assignment == 50 50 51 - Call anexternalweb serviceandsend alongsomeSOAPHeaders.89 +Secure a SOAP web service to confirm the outlined approach above. Focus on the apiKey part. 52 52 This assignment can be completed with the help of the (Academy) project that you have created/used in the previous assignment. 53 53 54 54 == 5. Key takeaways == 55 55 56 -* You can exchange data from: 57 - ** SOAP Header to Message Header 58 - ** Message Header to SOAP Header 59 -* You need the SOAP structure and the message header name to make it work 94 +* Crucial parts in the configuration are: 95 + ** Operation Name 96 + ** SOAP Webservice Namespace 97 + ** Validation 98 + ** Authentication 99 +* Hosting your SOAP web service in the eMagiz cloud results in standard HTTPS 100 +* Use a combination of client certificate + API key for authentication 60 60 61 61 == 6. Suggested Additional Readings == 62 62 ... ... @@ -64,6 +64,6 @@ 64 64 65 65 == 7. Silent demonstration video == 66 66 67 -{{video attachment="novice-soap-webservice-connectivity-soap- headers.mp4" reference="Main.Videos.Microlearning.WebHome"/}}108 +{{video attachment="novice-soap-webservice-connectivity-securing-your-soap-webservice.mp4" reference="Main.Videos.Microlearning.WebHome"/}} 68 68 69 69 )))((({{toc/}}))){{/container}}{{/container}}