API Connect

API Connect

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.


#API Connect
#Applicationintegration
#APIConnect
 View Only
  • 1.  Use Ip filter policy of Datapower in Apiconnect 2018

    Posted Sun December 01, 2019 06:48 PM
    ​Hi , I need to develop an api in apiconnect  and use the IP filtering policy of datapower. How we can use the datapower policy in apiconnect and use that.

    Thanks

    ------------------------------
    Harry Anadpur
    ------------------------------


  • 2.  RE: Use Ip filter policy of Datapower in Apiconnect 2018

    Posted Mon December 02, 2019 09:11 AM

    Hi Harry,

    You will need to create a custom policy where the main processing rule would have a stylesheet can get the current request's clientIP by using <xsl:variable name="ip" select="dp:client-ip-addr()"/> and you would used the dp:ip-addr-match extension function to determine if the client IP is within the range you wish.  Note that the ip-addr-match extension function does accept CIDR notation so you can check for the client IP being within a range of IPs.  If the IP isn't in range, the you'd use a dp:reject.  You can also customize your HTTP status code by having a stylesheet in your policy error rule that would do something like

    <xsl:call-template name="apim:error">
    <xsl:with-param name="httpCode" select="'403'" />
    <xsl:with-param name="httpReasonPhrase" select="'Forbidden'" />
    <xsl:with-param name="errorMessage" select="dp:variable('var://service/error-message')" />
    </xsl:call-template>

    Regards,

    Steve




  • 3.  RE: Use Ip filter policy of Datapower in Apiconnect 2018

    Posted Tue December 03, 2019 03:35 PM
    Thanks. Any link to refer.

    ------------------------------
    Harry Anadpur
    ------------------------------



  • 4.  RE: Use Ip filter policy of Datapower in Apiconnect 2018

    Posted Thu December 05, 2019 03:10 PM

    Hi Harry, 

    This question has come up from  time to time, so I just pulled my sample custom policy for this from my archives and placed in the API Connect Sample custom policies at https://github.com/ibm-apiconnect/policy (Look for clientIP-filter-policy). Again, just a sample, but give it a try and if nothing else it gives you a head start.  If it doesn't meet your needs, you can modify as needed to meet your requirements.

    Regards,
    Steve




  • 5.  RE: Use Ip filter policy of Datapower in Apiconnect 2018

    Posted Fri March 13, 2020 02:05 PM
    Hi Stephen , when I upload the policy it is giving me below error

    Error: The policy '(unnamed)' failed validation.
    - Does not match pattern ^([a-z0-9]+(-)*)*([a-z0-9])$ (context: (root).info.name, line: 5, col: 17)
    info.version is of incorrect type. Expected: string, Given: integer (context: (root).info.version, line: 6, col: 20)

    ------------------------------
    Harish Dhiman
    ------------------------------



  • 6.  RE: Use Ip filter policy of Datapower in Apiconnect 2018

    Posted Wed January 15, 2020 01:52 PM
    Let me know if you still need it because I developed it already

    ------------------------------
    Leandro Takeda
    ------------------------------



  • 7.  RE: Use Ip filter policy of Datapower in Apiconnect 2018

    Posted Fri March 13, 2020 11:26 AM
    Hi, as i am using apic 2018 , could you please help me to provide sample policy on this. 

    Thanks
    Harry

    ------------------------------
    Harish Dhiman
    ------------------------------



  • 8.  RE: Use Ip filter policy of Datapower in Apiconnect 2018

    Posted Fri March 13, 2020 11:26 AM
    Hi Leandro , cauld you please provide me the sample policy ?

    Thanks
    Harry

    ------------------------------
    Harish Dhiman
    ------------------------------