Commit Graph

13 Commits

Author SHA1 Message Date
Patrick Ohly 2fa3c3335a C++: replace boost::shared_ptr, boost::function, boost::bind
We can use std::shared_ptr and std::function instead now.

Lambdas are usually a better alternative to boost/std::bind. The
downside is the need to explicitly specify parameters completely. When
inlining callbacks entirely with lambdas, duplication of that
parameter list can be avoided.

Whenever possible, use std::make_shared to construct objects that are
tracked by std::shared_ptr.

Some objects need a std::weak_ptr during object destruction. For that
we have to use our own implementation of std::enable_shared_from_this,
with a matching creator function. The additional benefit is that we
can get rid of explicit static "create" methods by making that create
function a friend.

Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
2020-12-05 21:28:08 +01:00
Patrick Ohly bce7526da1 C++: simpler for loops
boost/foreach.hpp is no longer needed, range-based loops work
the same. With some helpers, even reverse iteration and
boost::make_split_iterator() can be handled the same way.

"auto" makes it possible to avoid explicitly spelling out the
expected type.

Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
2020-12-05 21:28:08 +01:00
Alberto Mardegan ff12834be1 AuthProvider: removed failure count
Remove the failure count from the getOAuth2Bearer() method, and add an
invalidateCachedSecrets() method instead.

This moves the logic of how to deal with failures back to the
AuthProvider backend and simplifies the session code, which only needs
to call invalidateCachedSecrets() when the token is wrong.
This will help implementing a similar logic for the getCredentials()
method, where authentication errors could lead to requesting a new
password.

[PO: avoid issue found via cppcheck: returning std::string::c_str() in
a method returning a std::string forces a string copy, which is
inefficient.]
2015-03-03 10:30:29 +01:00
Mateusz Polrola b747a8c2e4 identity: allow using and updating the "password" property
So far, only the "username" property was used once identity providers
were involved. The upcoming oauth2 provider uses the "password"
property for the refresh token and needs the ability to store a new
token if the OAuth2 server updates it.

Setting the new value will not always be possible (for example,
when running a command line operation where all properties were
provided on the command line without a permanent config). This still
needs to be handled.
2014-09-12 11:38:56 +02:00
Patrick Ohly de8461f802 code restructing: Exception, throwError()
Raising exceptions via throwError() looses the original source code
location information. Fixing that by explicitly passing that
information as additional parameter, created with the preprocessor
macro SE_HERE.

Several files included the complex SyncContext.h only because needed
throwError(). A better place for the revised implementation is the
Exception class which used to be in util.h, now Exception.h.

Simplifying the include statements exposed indirect include
dependencies and removed "using namespace std" from the compilation of
some source files which happened to rely on it. We want to get rid of
that name space polution, so fix the code instead of adding it back.
2014-05-02 16:43:52 +02:00
Patrick Ohly 7808af7c46 logging: debug output for password handling
Figuring out where credentials come from became harder. These debug
messages help. Perhaps they should even be logged as INFO messages
such that normal users can see them?
2013-10-01 09:28:37 +02:00
Patrick Ohly 83768d41ae config: add identity provider registry
Similar to the RegisterSyncSource concept, but trimmed down:
- virtual method creates instances
- keys have to be unique
2013-09-27 08:59:14 -07:00
Patrick Ohly 5d9aa1ac85 config: introduce AuthProvider
AuthProvider is the instance created by specific IdentityProvider
backends which then hands out username/password credentials or OAuth2
bearer tokens.
2013-09-27 08:59:14 -07:00
Patrick Ohly 526723acf5 config: first step towards modular identity providers
Let the conversion to username+password be handled by the
IdentityProvider module.
2013-09-27 08:59:14 -07:00
Patrick Ohly b7fa64f15c signon: revert accidental inclusion in master branch
The code wasn't ready and got pushed as part of some other change.
2013-08-02 22:02:03 +02:00
Patrick Ohly 7fdd878bc1 config: add identity provider registry
Similar to the RegisterSyncSource concept, but trimmed down:
- virtual method creates instances
- keys have to be unique
2013-08-02 13:15:27 +02:00
Patrick Ohly 03efa0c44d config: introduce AuthProvider
AuthProvider is the instance created by specific IdentityProvider
backends which then hands out username/password credentials or OAuth2
bearer tokens.
2013-08-02 13:15:27 +02:00
Patrick Ohly 80e68a747a config: first step towards modular identity providers
Let the conversion to username+password be handled by the
IdentityProvider module.
2013-08-02 13:15:27 +02:00