BasicAuthentication policy fails to decode non english character which is in password

Basic Authentication policy fails to decode the non english character correctly which is in password. Policy execution is success, however the password decoded is not the correct password which fails the authentication.

Is there any solution to this?

0 9 199
9 REPLIES 9

Wow, That is interesting. I just looked at the tests for this policy; there are tests for unicode characters. I suppose UTF-8. Are you sure you're encoding the "non english" character correctly?

My own tests in Apigee show that it works correctly. Are you using Apigee SaaS? Maybe there is a difference in older versions of Apigee on-premises.

Please find attached an API Proxy that I used to test this.

decode-basicauth.zip

Apigee version is 4.18.

I decoded Basic auth in online, which decodes correctly, but not in the policy. I will check your Proxy , to understand is there is something which I need to do.

Hi Dino,

We use latest version of apigee private cloud. Is there any other place we need to look at

Hi ... by "latest" are you referring to 4.50 ?

It should work correctly.

If you think this is not working correctly, Can you give me a working example of a proxy that gives the results you are describing?

Hi Dino,

It is Version 4.19.06.00 private cloud based. I have tried my example in my private Apigee account and it works. There is no issue in the proxy. Not sure whether we need to do some settings to accept UTF instead of ASCII

I see... So it's a bug in OPDK. But not present in the hosted Apigee.

That suggests that a bug has been fixed and released.

can you try in OPDK 4.50?

You may want to contact Apigee support to ask them to find the bug reference number and determine which patch release of 4.19.06 may include the fix, and to confirm that 4.50 includes the fix.

In the meantime your workaround is to use one of these:

  • Javascript. policy
  • Python policy

Not applicable

If you are still facing the issue, can you try the same using javascript base64 decode in your proxy and test?

Not applicable

You can use python script as below to decode basic authentication

import base64

basicauth = flow.getVariable("request.header.Authorization")

encoded = basicauth[6:]
data = base64.b64decode(encoded)
ind = data.index(':')
username = data[:ind]
password =  data[(ind+1) :]

Hi Ajitav

Yes I will check that out. But need to understand why the Basic Auth policy is not working. Hence that as first option