Changes for page Multipart form-data
Last modified by Erik Bakker on 2024/06/17 11:39
From version 19.1
edited by Erik Bakker
on 2022/08/05 14:33
on 2022/08/05 14:33
Change comment:
There is no comment for this version
To version 11.1
edited by Erik Bakker
on 2022/07/26 13:40
on 2022/07/26 13:40
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 - Multipartform-data1 +API Gateway Security - External IDP - Content
-
... ... @@ -1,5 +1,5 @@ 1 1 {{container}}{{container layoutStyle="columns"}}((( 2 - Sometimeswhenyoucall an externalRESTendpoint,theyrequire youtosendmeta information and one or more "attachments"in one calltotheRESTendpoint.To makethis possible,youneedtondtheinformationwiththecontentTypealledmultipart/form-data. In this microlearning, we will discusshowyoucanconfigureavalidmessagewithinthe eMagizplatformthat allows youtosendoutmessageswith thiscontentType andhave themacceptedby theendpointinquestion.2 +In the crash course on the API Gateway we discussed the various options available to [[secure>>doc:Main.eMagiz Academy.Microlearnings.Crash Course.Crash Course API Gateway.crashcourse-api-gateway-security.WebHome||target="blank"]] your API Gateway properly. In this microlearning, we will expand our knowledge on that topic by looking at a special case of securing your API Gateway. That case is special as you use an external identity provider (IDP) to govern the roles and users that have rights on your API Gateway. 3 3 4 4 Should you have any questions, please get in touch with [[academy@emagiz.com>>mailto:academy@emagiz.com]]. 5 5 ... ... @@ -9,78 +9,51 @@ 9 9 10 10 == 2. Key concepts == 11 11 12 -This microlearning focuses on configuring amultipart/form-datamessagewithin eMagiz to ensureit issentcorrectly toanendpoint.12 +This microlearning focuses on using an external IDP to validate whether a user is authorized to execute a certain action on your API Gateway and what configuration is needed in eMagiz to make this work. 13 13 14 -Key aspects are: 14 +* The Token and Issuer URL of the external IDP need to be known 15 +* Users and Roles under User Management need to be manually configured and maintained to keep them in sync with the external IDP 15 15 16 -* Defining the boundary that separates the parts of the message 17 -* Defining the content types of each part of the message 18 -* Construction of the complete message according to the specification 17 +== 3. External IDP == 19 19 20 - ==3. Multipart form-data==19 +In the crash course on the API Gateway we discussed the various options available to [[secure>>doc:Main.eMagiz Academy.Microlearnings.Crash Course.Crash Course API Gateway.crashcourse-api-gateway-security.WebHome||target="blank"]] your API Gateway properly. In this microlearning, we will expand our knowledge on that topic by looking at a special case of securing your API Gateway. That case is special as you use an external identity provider (IDP) to govern the roles and users that have rights on your API Gateway. 21 21 22 - Sometimes whenyou call anexternalRESTendpoint,theyrequire youtosendmetainformationandoneor more "attachments"inonecallto theREST endpoint.Tomake thispossible, you needto sendtheinformationwith the contentType called multipart/form-data. In this microlearning,wewill discusshowyou can configure a validmessagewithin theeMagiz platformthatallowsyouto send out messageswith thiscontentTypeandhavethemacceptedbythe endpointin question.21 +When selecting the option OAuth2.0 (or OpenID Connect) you have the option to use the IDP provided by eMagiz which makes the configuration easy or you could use an external IDP which you have control over and want to use for this purposes. 23 23 24 - Keyaspectsare:23 +In this microlearning we will highlight what you need to configure in Design and Deploy to make this work within the tooling of eMagiz. 25 25 26 -* Defining the boundary that separates the parts of the message 27 -* Defining the content types of each part of the message 28 -* Construction of the complete message according to the specification 25 +=== 3.1 Design === 29 29 30 - To actually constructthemessagetherea severalstepsneededto make itork.Luckily,mostofthe stepsneededhavetodo with conceptswehavealready discussed inpreviousmicrolearnings.As youcanimagine based on what mulipart/form-dataentailsweneeda wayto bothstorethemetainformationandthefile(s)we want to sendto the externalparty.To doso it is advisableto put themetadatain one(ormultiple) header(s) and use thefilecontentas payload.Thisyoucan achievewitha headerenricherand standard transformer.27 +On the security level of the API Gateway in Design you need to select the desired option, for example OAuth2.0. Instead of not filling in the token and issuer URL, indicating that you want to use the eMagiz IDP, you need to fill these in to reference the IDP of your choice. Below you see an example of how this could be configured. 31 31 32 - Once the filecontent isyourpayload youneed toakesurethat thedata is"raw"innature. So when you haveabase64 encoded string you shoulddecode the stringbeforesendingit to the endpoint.29 +[[image:Main.Images.Microlearning.WebHome@expert-securing-data-traffic-api-gw-security-external-idp-security-config-design.png]] 33 33 34 - On topofthatwe needtodefine thecontentTypeheaderasfollows.31 +Note that the environmentID in this example should be replaced with an actual environmentID that references your environment. 35 35 36 - [[image:Main.Images.Microlearning.WebHome@expert-data-handling-multipart-form-data--content-type-header-config.png]]33 +=== 3.2 Deploy === 37 37 38 - Afterouhaveset the stageyou canusea standardtransformercomponenttobuildyourmessageinthe correctmanner.Tobuilditcorrectly you need totake thefollowingintoaccount:35 +Normally, eMagiz will automatically update the User Management information based on the configuration in Design. However, because the identity check is not done by eMagiz but by an external party you need to manually enter the roles and users and configure the scope correctly on role level. 39 39 40 -* Each part of the message needs to be seperated by a boundary 41 -* The message needs to start with a boundary and finish with a boundary 42 -* Line breaks are needed to differentiate between the boundary and the text content 43 -* No line break is needed when the content is not text based 37 +To do so navigate to User Management in Deploy and add the users you want manually by pressing the New button and providing them with a name. Do subsequently the same for the roles. On role level do not forget to correctly enter the scope to make the call work. Note that the help text on the scope level gently reminds you what you need to do to make this work. 44 44 45 - Givenall thisyoucan write the followingSpELexpressionhatllyield a desirableut:39 +[[image:Main.Images.Microlearning.WebHome@expert-securing-data-traffic-api-gw-security-external-idp-scope-configuration.png]] 46 46 47 -{{ code}}test{{/code}}41 +{{warning}}When implementing this you would be the first to do so with this setup. This means there might be some unexpected behavior when configuring this.{{/warning}} 48 48 49 -Most users would think that communication via queues to connect two separate eMagiz models is a bright idea. However, this is something that we do not encourage. We discourage this for several practical and technical reasons alike. 50 - 51 -When looking at the practical side of things getting it configured correctly is time-consuming and an error-prone action (as is evident by the question). Furthermore, it can lead to unexpected situations where you make a typo to listen to a queue on which no messages are provided. This queue will, however, be registered on the JMS level (when you activate the flow in question with the custom configuration), which can lead to confusing queue statistics and even more troublesome false-positive alerting based on missing queue metrics or missing consumers. 52 - 53 -On top of that, when you allow one model to write and read from queues registered in another model, maintaining both models will become very complex. This holds for the ones working on the project at the moment but also for those working on it at a later stage and does that need to provide (incidental) support on the environments. 54 - 55 -Another practical reason for not wanting this is that we do not actively support this use case from eMagiz. This means that when we update our technical infrastructure, we will not consider this scenario. This could lead to additional work in the future and reduced stability of your solution. 56 - 57 -From the technical point of view, the consequence of this construction is that both models need to know each other certificates and credentials, which are not considered secure. On top of that, because you, theoretically, can exchange data from any queue to any queue, you could create a situation in which updates in one model trigger changes in the other model (i.e., when using the same data model) that are unexpected (and frankly unwanted). 58 - 59 -We advise using functionality that makes it explicit that both models function independently of each other. From eMagiz, we consider two valid alternatives for this: 60 -- Using a web service as a communication layer between the two models. This web service can be REST or SOAP and has been implemented before 61 -- Using the Event Streaming functionality of eMagiz to write and read from topics. 62 - 63 -Both alternatives have the benefit that the security can be tight and explicit (i.e., only model A can write/post data to model B). Furthermore, managing the solution becomes much easier as it uses the standard functionality within the platform. Therefore, we have no plans to support this approach in the product. 64 - 65 65 == 4. Assignment == 66 66 67 -Consider what your criteria are when communicating between models and compare them to our criteria. 68 -This assignment can be completed with the help of the (Academy) project you created/used in the previous assignment. 45 +No assignment 69 69 70 70 == 5. Key takeaways == 71 71 72 -* Consider the following when communication between two models 73 -** Security 74 -** Loose coupling 75 -** Maintainability 76 -** Clarity 49 +* The Token and Issuer URL of the external IDP need to be known 50 +* Users and Roles under User Management need to be manually configured and maintained to keep them in sync with the external IDP 51 +* When implementing this you would be the first to do so with this setup. 77 77 78 78 == 6. Suggested Additional Readings == 79 79 80 -If you are interested in this topic please read the helptext sin theplatform andreadthefollowinglink:55 +If you are interested in this topic and want more information, please read the help text provided by eMagiz. 81 81 82 -* https://www.sobyte.net/post/2021-12/learn-about-http-multipart-form-data/ 83 - 84 84 == 7. Silent demonstration video == 85 85 86 86 As this is more of theoretical microlearning, there is no video accompanying the microlearning.)))((({{toc/}}))){{/container}}{{/container}}