Hi, i have a question about basic auth. I am not interested in actually validating credentials. I am interested in two things 1. getting the policies i created to actually work and 2. getting apigee management to encode the credentials passed. I am using apigee trial account.
So i followed apigee documentation and first created a key value map.
BasicAuthCredentials with username and password variables populated.
(i am skipping steps such as creating api apps, api products, etc).
Then i created policies for a specific api proxy
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<KeyValueMapOperations name="getUsername" mapIdentifier="BasicAuthCredentials">
<Scope>apiproxy</Scope>
<Get assignTo="credentials.username" index="1">
<Key>
<Parameter ref="BasicAuth.credentials.username"/>
</Key>
</Get>
</KeyValueMapOperations>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<KeyValueMapOperations name="getPassword" mapIdentifier="BasicAuthCredentials">
<Scope>apiproxy</Scope>
<Get assignTo="credentials.password" index="1">
<Key>
<Parameter ref="BasicAuth.credentials.password"/>
</Key>
</Get>
</KeyValueMapOperations>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<BasicAuthentication async="false" continueOnError="false" enabled="true" name="Basic-Authentication-1">
<DisplayName>Basic Authentication-1</DisplayName>
<Operation>Encode</Operation>
<IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
<User ref="BasicAuth.credentials.username"/>
<Password ref="BasicAuth.credentials.password"/>
<AssignTo createNew="false">request.header.Authorization</AssignTo>
<Source>request.header.Authorization</Source>
</BasicAuthentication>
Then i tested via the api console (while tracing within the api management gateway).
I select basic auth and then entered username and password as stored in key map.
i get the following error
HTTP/1.1 500 Internal Server Error
- Date:
- Tue, 08 Aug 2017 20:15:38 GMT
- Content-Length:
- 150
- Connection:
- keep-alive
- Content-Type:
- application/json
- Server:
- Apigee Router
<code>{"fault":{"faultstring":"Unresolved variable : BasicAuth.credentials.username","detail":{"errorcode":"steps.basicauthentication.UnresolvedVariable"}}}
<code>can anyone help?
<br>
,
So, i am trying to understand how to do basic authentication.. i am not trying to authenticate (which many people seem to assume when they answer this type of question).. i am merely trying to do the following 1. Encode the credentials. 2. get the policies to work!!!. I am using apigee edge trial account.
So i followed the example on apigee. in the dev environment, i created the key value map “BasicAuthCredentials” with a username and password.
Then in my proxy i create the following policies
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<KeyValueMapOperations name="getUsername" mapIdentifier="BasicAuthCredentials">
<Scope>apiproxy</Scope>
<Get assignTo="credentials.username" index="1">
<Key>
<Parameter ref="BasicAuth.credentials.username"/>
</Key>
</Get>
</KeyValueMapOperations>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<KeyValueMapOperations name="getPassword" mapIdentifier="BasicAuthCredentials">
<Scope>apiproxy</Scope>
<Get assignTo="credentials.password" index="1">
<Key>
<Parameter ref="BasicAuth.credentials.password"/>
</Key>
</Get>
</KeyValueMapOperations>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<BasicAuthentication async="false" continueOnError="false" enabled="true" name="Basic-Authentication-1">
<DisplayName>Basic Authentication-1</DisplayName>
<Operation>Encode</Operation>
<IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
<User ref="BasicAuth.credentials.username"/>
<Password ref="BasicAuth.credentials.password"/>
<AssignTo createNew="false">request.header.Authorization</AssignTo>
<Source>request.header.Authorization</Source>
</BasicAuthentication>
Then i go to api console and before i execute, i select basic auth, which ask for username and password, which i supply (the values i created in key map).
I get this eror
HTTP/1.1 500 Internal Server ErrorDate:Tue, 08 Aug 2017 20:15:38 GMTContent-Length:150Connection:keep-aliveContent-Type:application/jsonServer:Apigee Router{"fault":{"faultstring":"Unresolved variable : BasicAuth.credentials.username","detail":{"errorcode":"steps.basicauthentication.UnresolvedVariable"}}}<br>