Kiran Kumar
Kiran Kumar

Reputation: 1

WSO2 APIM Authentication

  1. I have a requirement to authenticate a user who wants to access an API with his credentials (un/pwd) with basic authentication or digest auth
  2. Also pass the required credentials(un/pwd) in the request to authenticate the access to backend service

My synapse extracted config looks like this:

<filter source="$ctx:AM_KEY_TYPE" regex="PRODUCTION">
<then>
<property name="api.ut.backendRequestTime"
expression="get-property('SYSTEM_TIME')"/>
<property name="password" 
expression="wso2:vault-lookup('PayAdmin--    ZenoAPI51.0')"/>
<property name="unpw" 
expression="fn:concat('user',':',get-property('password'))"/>
<property name="Authorization"
expression="fn:concat('Basic ', base64Encode(get-property('unpw')))"
scope="transport"/>
<send>
<endpoint name="PayAdmin--ZenoAPI5_APIproductionEndpoint_0">
<http uri-template="http://localhost:8080/payment/{uri.var.name}"/>
</endpoint>
</send>
</then>

What i want to know is:

curl -X POST --header "Content-Type: application/json" --header "Accept: application/json" --header "Authorization: Bearer 2e13c9b3c8717f43d093cfc7c63994bb" -d "{}" http://<IP address of APIM Server>:8280/Zeno1/1.0.0/payment/name

This curl can only take bearer token but how to pass user/pwd for API and user/pwd for backend in the curl

Upvotes: 0

Views: 220

Answers (2)

IlmMicha
IlmMicha

Reputation: 11

Regarding your second question: For Basic Authentication towards the backend you can configure a general Password in the Publisher in step Implement -> Show More Options -> Endpoint Security Scheme: set to Secured and provide Credentials (see: https://docs.wso2.com/display/AM1100/Basic+Auth)

If user specific credentials have to be provided the user should set the "Authentication: Basic base64(username:password)" in the HTTP header, the header will get passed to the backend.

Upvotes: 1

farasath
farasath

Reputation: 3011

curl -X POST --header "Content-Type: application/json" --header "Accept: application/json" --header "Authorization: **Basic** **[base64encode(username:password)]**" -d "{}" http://<IP address of APIM Server>:8280/Zeno1/1.0.0/payment/name

[base64encode(username:password)] replace this with base64 encode string of "username:password"

Upvotes: 0

Related Questions