(Migrated) Accessing basic_auth credentials in service

(This message has been automatically imported from the retired mailing list)

Hi list,

I have an outgoing HTTP connection to a specific endpoint. This connection
is secured and an HTTP Basic Auth has been defined and assigned to the
plain_http connection.

Now let’s say that I need to retrieve those credentials in one of my
services to download data from a dynamic “one-time-only” URL.
Is there a way to do this? So far my solution is to store those credentials
also in redis but it makes no sense to have them stored in 2 different
places.

Thanks in advance,
Luca

On 27/01/16 10:25, Luca Valtulina wrote:

Now let’s say that I need to retrieve those credentials in one of my
services to download data from a dynamic “one-time-only” URL.
Is there a way to do this? So far my solution is to store those
credentials also in redis but it makes no sense to have them stored in 2
different places.

Hi Luca,

this would be here:

All security definitions are in
self.worker_store.request_dispatcher.url_data, for instance
basic_auth_config or wss_config and so on.

Alternatively, if you know upfront the name of the definition, you can
just use this call to return it:

self.worker_store.request_dispatcher.url_data.basic_auth_get(name)

Thanks, works like a charm.

Still cannot find any information about it in the docs and I find that way
of accessing it pretty complex. Maybe it would be better to make security
definition accessible straight from the connection object where it has been
assigned to.

Think at something like this:

test_conn = self.outgoing.plain_http.get(‘test’)
if test_conn[‘sec_type’] == ‘basic_auth’:
basicAuth = test_conn.get_basic_auth()

Just my two cents.
Luca

2016-01-27 11:54 GMT+01:00 Dariusz Suchojad dsuch@zato.io:

On 27/01/16 10:25, Luca Valtulina wrote:

Now let’s say that I need to retrieve those credentials in one of my
services to download data from a dynamic “one-time-only” URL.
Is there a way to do this? So far my solution is to store those
credentials also in redis but it makes no sense to have them stored in 2
different places.

Hi Luca,

this would be here:

https://gist.github.com/dsuch/12c489e846e1173a48e4

All security definitions are in
self.worker_store.request_dispatcher.url_data, for instance
basic_auth_config or wss_config and so on.

Alternatively, if you know upfront the name of the definition, you can
just use this call to return it:

self.worker_store.request_dispatcher.url_data.basic_auth_get(name)

On 27/01/16 12:14, Luca Valtulina wrote:

Still cannot find any information about it in the docs and I find that
way of accessing it pretty complex. Maybe it would be better to make
security definition accessible straight from the connection object where
it has been assigned to.

Yes, this is not documented because that’s part of internal APIs that
have not been exposed in a more user-friendly way yet.

As for accessing it directly from outgoing connections, this is also
possible - you said it was a one-time URL so I somehow thought it would
not have a security definition attached directly.

Here it is:

out = self.outgoing.plain_http[‘my.conn’]

self.logger.info(out.conn.config)
self.logger.info(out.conn.config_no_sensitive)
self.logger.info(out.conn.auth)