Layer7 API Management

 View Only
  • 1.  Can Gateway Perform UTF-8 Encoding transforming string into bytes (and/or byte arrays)?

    Posted Sep 30, 2020 05:18 PM
    Hello all,

    I am working on a policy that essentially is trying to do the SAS Token Generation done within Azure Service Bus, but within the Gateway.

    Ex: https://docs.microsoft.com/en-us/rest/api/eventhub/generate-sas-token

    The portion I am hung up on within the Gateway, is UTF-8 encoding string into a byte array. I know we can easily create an array once I have the values in bytes, but I cannot exactly figure out how to do UTF8 encoding on a string without going with custom assertions. 

    1) The encode/decode assertion seems to only support Base16 or UTF16 encoding, and not Base8/UTF8? Is this correct?

    2) Does anyone have any idea on if this is possible without going to a custom assertion? Maybe through XSLT or some "smart" policy construction with other assertions?

    Thanks.


  • 2.  RE: Can Gateway Perform UTF-8 Encoding transforming string into bytes (and/or byte arrays)?

    Broadcom Employee
    Posted Oct 01, 2020 03:13 PM
    Edited by Barry Stern Oct 01, 2020 03:13 PM
    Hello Nathan,


    I am sure we can figure out the proper assertions to do what you need but was just wondering if using Azure AD token is an option for you instead of the SAS token. 

    Seem like this is recommended approach by MS
    https://docs.microsoft.com/en-us/azure/event-hubs/authenticate-shared-access-signature
    Microsoft recommends that you use Azure AD credentials when possible as a security best practice, rather than using the shared access signatures, which can be more easily compromised. 

    Barry



  • 3.  RE: Can Gateway Perform UTF-8 Encoding transforming string into bytes (and/or byte arrays)?

    Posted Oct 01, 2020 04:08 PM
    Hey Barry,

    Thanks for the reply.

    I have sent this back to the client to see if they agree to change the use case slightly and go with Azure AD.

    ---

    In the meantime, if anyone else has some ideas around UTF8 encoding, let me know.

    Thanks!


  • 4.  RE: Can Gateway Perform UTF-8 Encoding transforming string into bytes (and/or byte arrays)?

    Posted Feb 16, 2021 04:46 AM
    I have created a while back this simple custom assertion.

    Key point is that you can add more transformations via updating a simple JAVA class, without deploying the SDK.

    https://github.com/guyplusplus/String-Simple-Transform-Custom-Assertion

    Note that the assertion itself has already some UTF-8 capability.


  • 5.  RE: Can Gateway Perform UTF-8 Encoding transforming string into bytes (and/or byte arrays)?

    Posted Feb 18, 2021 04:14 PM
    Thank you for the reply!