use string expansion in exim4's authenticator - exim

I need to extract a valid email address like a#example.com in exim4's authenticator, here is what I did:
gmail_login:
driver = plaintext
public_name = LOGIN
hide client_send = : ${reduce{${addresses:$h_from:}}{}{${if eq{$value}{}{$item}{$value}}}} : my password
the string has been tested under exim -bem , and it's working, but when put under client_send option, I always got error:
smarthost T=remote_msa defer (0): expansion of "${reduce{${addresses" failed in gmail_login authenticator: "${addresses" is not a known operator (or a } is missing in a variable reference)
what I'm missing here? thanks

Auth occurs before any data available and there is no headers to extract addresses from.

Related

ms sql connection string with semi colon in password failing to connect

Am working on anypoint studio 6.6.8 with runtime 3.9.4EE.
I have the following mssql generic database connection string.
jdbc:sqlserver://ABC.org:59000;databaseName=master;username=nrp;password=*37n%3b#wu;5r:;_1z~(f{1y{j
Test connection gives me the following error:
Test connection failed:
org.mule.module.db.internal.domain.connection.ConnectionCreationException: Cannot get connection for URL jdbc:sqlserver://ABC.org:59000;databaseName=master;username=nrp;password=<<credentials>>;5r:;_1z~(f{1y{j: The connection string contains a badly formed name or value
PS: I have 2 semi colons in password
I have seen similar question raised here earlier a few times, hence my question might look repetitive.
however I tried the following solutions given in the replies. none of them worked. Please let me know if you have any alternate solution.
Enclosing the password in single quotes.
adding \ in front of ;
Enclosing password within double quotes or {}
Am not the admin hence removing ; from password cannot be done.
The connection string is in a format known as JAVA JDBC URL. It is similar to a normal URL. Many characters are not allowed in URLs and have to be encoded with the URL encoding method. Try using URL encoding for the entire URL. You can do it with most languages or online pages, though you might want to avoid public pages for sensitive information like passwords.
Example in Groovy: https://stackoverflow.com/a/10187493/721855.
Example in Python: https://stackoverflow.com/a/5607708/721855.
Thank you #aled
So the {} did work. I was doing it the wrong way.
I was encrypting the password & later concatenating {} to the decrypted password right b4 passing the connection string.
What worked was that I enclosed the password in {} first & then encrypted it.

python requests login with redirect

I'd like to automate my log in to my bank to automatically fetch my transactions to stay up-to-date with spendings and earnings, but I am stuck.
The bank's login webpage is: https://login.bancochile.cl/bancochile-web/persona/login/index.html#/login
I am using python's request module with sessions:
urlLoginPage = 'https://login.bancochile.cl/bancochile-web/persona/login/index.html'
urlLoginSubmit = 'https://login.bancochile.cl/oam/server/auth_cred_submit'
username = '11.111.111-1' # this the format of a Chilean National ID ("RUT")
usernameFormatted = '111111111' # same id but formatted
pw = "password"
payload = [
("username2", usernameFormatted),
("username2", username),
("userpassword", pw),
("request_id", ''),
("ctx", "persona"),
("username", usernameFormatted),
("password", pw),
]
with requests.Session() as session:
login = session.get(urlLoginPage)
postLogin = session.post(
urlLoginSubmit,
data=payload,
allow_redirects=False,
)
redirectUrl = postLogin.headers["Location"]
First I find that the form data has duplicated keys, so I am using the payload as a list of tuples. From Chrome's inspect I find the form data to be like this:
username2=111111111&username2=11.111.111-1&userpassword=password&request_id=&ctx=persona&username=111111111&password=password
I've checked the page's source code to look for the use of a csrf token, but couldn't find any hint of it.
What happens is that the site does a redirect upon submitting the login data. I set allow_redirects=False to catch the redirect url of the post under the Location-header. However, here is the problem. Using the web-browser I know that the redirect url should be https://portalpersonas.bancochile.cl/mibancochile/rest/persona/perfilamiento/home, but I always end up on an error page when using the above method (https://login.bancochile.cl/bancochile-web/contingencia/error404.html). (I am using my own, correct login credentials to try this)
If I submit the payload in a wrong format (e.g. by dropping a key) I am redirected to the same error-page. This tells me that probably something with the payload is incorrect, but I don't know how to find out what may be wrong.
I am kind of stuck and don't know how I can figure out where/how to look for errors and possible solutions. Any suggestions on how to debug this and continue or ideas for other approaches would be very welcome!
Thanks!

How do I test if provider credentials are valid in apache libcloud?

I was trying to create a driver for openstack using apache libcloud. It doesn't raise any error even if the user credentials are wrong. So When i checked the faq i found an answer as given in the link
Apache libcloud FAQ
But it doesn't seem to be effective since querying each time to check whether the user is authenticated will reduce the performance if the query returns a bulk of data.
When i checked the response i got from the api there is a field called driver.connection.auth_user_info and i found that the field is empty if the user is not authenticated. So can i use this method as a standard? Any help is appreciated
An openstack driver for libcloud is already available:
from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver
os = get_driver(Provider.OPENSTACK)
params = {'key': 'username', 'ex_force_service_region':'regionOne',
'ex_force_service_name':'nova', 'ex_force_auth_version':'2.0_password',
'ex_force_auth_url':'http://127.0.0.1:5000',
'ex_force_service_type':'compute', 'secret':'password',
'ex_tenant_name':'tenant'}
driver = os(**params)
But libcloud does not check the credentials by just creating the driver object. Instead, the creds will be validated only when a request is sent. If the internal exception InvalidCredsError is thrown the credentials are invalid, and an own variable could be set:
from libcloud.common.types import InvalidCredsError
validcreds = False
try:
nodes = driver.list_nodes()
if nodes.count >= 0:
validcreds = True
except InvalidCredsError:
print "Invalid credentials"
except Exception as e:
print str(e)
I would not rely on the internal variable auth_user_info because it could change over time.

LDAP error on bind method when trying to connect to LDAP

At my end(locally), I am using Sun ONE LDAP server, and where my application is deployed, they use MS AD. I store the values of User Name and Password (LDAP user name and password) in one table. In Sun ONE, I precede my user name with "cn=" and at my end I am able to connect to LDAP server, but where the application is deployed, the get bind error :-
Bind: Error: netscape.ldap.LDAPException: error result (49); 80090308: LdapErr: DSID-0C090334, comment: AcceptSecurityContext error, data 525, vece
I have my piece of code as follows for connection :-
try {
conn.connect(ldapHost,ldapPort);
}
catch(LDAPException ldapexception)
{
ldapexception.printStackTrace(System.out);
}
try {
conn.bind(ldapVersion,loginDN,loginDN_Password);
}
catch(LDAPException ldapexception)
{
ldapexception.printStackTrace(System.out);
}
I am getting this error at bind.
I googled about this error, and I found that login credentials is the problem.
But I have verified at their end, the login credentials are correct, the only difference at my end and their end is that I precede my user name with "cn=" and they do not.
I tried doing the same, but still getting the same error.
Can anyone help me on this ?
The purpose of the BIND request is to exchange authentication information between client and server. If the BIND was successful, a SUCCESS result code is returned to the client in the BIND response, along with any controls. The name or bind DN must be an LDAP DN as defined in RFC4511 and RFC4514, therefore it must have the naming attribute (cn in your case).

AuthSubUtil.getRequestUrl

I try to redirect the user to Google calendar and get his authorization so that I can combine events on his Google Calendar and my own calendar, but I can't get the TOKEN querystring somehow :(
Dim tokenURL As String = AuthSubUtil.getRequestUrl("http://localhost:54522/scripts/wbmodules/test.aspx/RetrieveToken", "http://www.google.com/calendar/hosted/mydomain.nl/", False, False)
I see login and password page but when I enter information and try to redirect to my own website, I get this error message
The page you requested can not be displayed. Another site was requesting access to your mydomain account, but the format of the request was incorrect.
The parameter 'scope' is incorrect or missing.
Finally the mistake is found, I was using the wrong 'scope'
Instead of "http://www.google.com/calendar/hosted/mydomain.nl/"
I should have used more general term
"http://www.google.com/calendar/feeds/"
So the correct version is as follows
Dim tokenURL As String = AuthSubUtil.getRequestUrl("http://localhost:54522/scripts/wbmodules/test.aspx/RetrieveToken", "http://www.google.com/calendar/feeds/", False, False)