Skip to content
This repository has been archived by the owner on Oct 10, 2019. It is now read-only.

Commit

Permalink
Add new config setting passwordeval
Browse files Browse the repository at this point in the history
Add new config setting `passwordeval` for all external APIs.
Add existing config setting `passwordfile` to all remaining APIs.
Refactor username and password handling for all external APIs into own class.
  • Loading branch information
x4121 committed Mar 8, 2017
1 parent abaad74 commit 112fb35
Show file tree
Hide file tree
Showing 20 changed files with 346 additions and 140 deletions.
13 changes: 10 additions & 3 deletions doc/configcommands.dsv
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ feedhq-flag-star|<flag>|""|If this is set and FeedHQ support is used, then all a
feedhq-login|<login>|""|This variable sets your FeedHQ login for FeedHQ support.|feedhq-login "your-login"
feedhq-min-items|<number>|20|This variable sets the number of articles that are loaded from FeedHQ per feed.|feedhq-min-items 100
feedhq-password|<password>|""|This variable sets your FeedHQ password for FeedHQ support. Double quotes should be escaped, i.e. you should write +{backslash}"+ instead of +"+.|feedhq-password "here_goesAquote:{backslash}""
feedhq-passwordfile|<path-to-file|""|A more secure alternative to the above, by storing your password elsewhere in your system.|feedhq-passwordfile "path-to-file"
feedhq-passwordfile|<path-to-file>|""|A more secure alternative to the above, by storing your password elsewhere in your system.|feedhq-passwordfile "path-to-file"
feedhq-passwordeval|<command>|""|Another secure alternative, is providing your password from an external command that is evaluated during login. This can be used to read your password from a gpg encrypted file or your system keyring.|feedhq-passwordeval "command some-parameter"
feedhq-show-special-feeds|[yes/no]|yes|If this is set, then "special feeds" like "People you follow" (articles shared by people you follow), "Starred items" (your starred articles) and "Shared items" (your shared articles) appear in your subscription list.|feedhq-show-special-feeds "no"
feedlist-format|<format>|"%4i %n %11u %t"|This variable defines the format of entries in the feed list. See the respective section in the documentation for more information on format strings.|feedlist-format " %n %4i - %11u -%> %t"
feedlist-title-format|<format>|"N %V - Your feeds (%u unread, %t total)%?T? - tag `%T'&?"|Format of the title in feed list. See "Format Strings" section of Newsbeuter manual for details on available formats.|feedlist-title-format "Feeds (%u unread, %t total)"
Expand All @@ -56,6 +57,8 @@ max-items|<number>|0|Set the number of articles to maximally keep per feed. If t
newsblur-login|<login>|""|This variable sets your NewsBlur login for NewsBlur support.|newsblur-login "your-login"
newsblur-min-items|<number>|20|This variable sets the number of articles that are loaded from NewsBlur per feed.|newsblur-min-items 100
newsblur-password|<password>|""|This variable sets your NewsBlur password for Newsblur support. Double quotes should be escaped, i.e. you should write +{backslash}"+ instead of +"+.|newsblur-password "here_goesAquote:{backslash}""
newsblur-passwordfile|<path-to-file>|""|A more secure alternative to the above, by storing your password elsewhere in your system.|newsblur-passwordfile "path-to-file"
newsblur-passwordeval|<command>|""|Another secure alternative, is providing your password from an external command that is evaluated during login. This can be used to read your password from a gpg encrypted file or your system keyring.|newsblur-passwordeval "command some-parameter"
newsblur-url|<url>|"https://newsblur.com"|Configures the URL where the newsblur instance resides.|newsblur-url "https://localhost"
notify-always|[yes/no]|no|If no, notifications will only be made when there are new feeds or articles. If yes, notifications will be made regardless.|notify-always yes
notify-beep|[yes/no]|no|If yes, then the speaker beep on new articles.|notify-beep yes
Expand All @@ -66,14 +69,17 @@ notify-xterm|[yes/no]|no|If yes, then the xterm window title will be set to a no
ocnews-flag-star|<character>|""|If this is set and ownCloud News support is used, then all articles that are flagged with the specified flag are being "starred" in ownCloud News.|ocnews-flag-star "s"
ocnews-login|<username>|""|Sets the username to use with the ownCloud instance.|ocnews-login "user"
ocnews-password|<password>|""|Configures the password to use with the ownCloud instance. Double quotes should be escaped, i.e. you should write +{backslash}"+ instead of +"+.|ocnews-password "here_goesAquote:{backslash}""
ocnews-passwordfile|<path-to-file>|""|A more secure alternative to the above, by storing your password elsewhere in your system.|ocnews-passwordfile "path-to-file"
ocnews-passwordeval|<command>|""|Another secure alternative, is providing your password from an external command that is evaluated during login. This can be used to read your password from a gpg encrypted file or your system keyring.|ocnews-passwordeval "command some-parameter"
ocnews-url|<url>|""|Configures the URL where the ownCloud instance resides.|ocnews-url "https://localhost/owncloud"
ocnews-verifyhost|[yes/no]|yes|If this is set to no, the connection the ownCloud instance will not verify the certificate's name against the host's name.|ocnews-verifyhost no
oldreader-flag-share|<flag>|""|If this is set and The Old Reader support is used, then all articles that are flagged with the specified flag are being "shared" in The Old Reader so that people that follow you can see it.|oldreader-flag-share "a"
oldreader-flag-star|<flag>|""|If this is set and The Old Reader support is used, then all articles that are flagged with the specified flag are being "starred" in The Old Reader and appear in the list of "Starred items".|oldreader-flag-star "b"
oldreader-login|<login>|""|This variable sets your The Old Reader login for The Older Reader support.|oldreader-login "your-login"
oldreader-min-items|<number>|20|This variable sets the number of articles that are loaded from The Old Reader per feed.|oldreader-min-items 100
oldreader-password|<password>|""|This variable sets your The Old Reader password for The Old Reader support. Double quotes should be escaped, i.e. you should write +{backslash}"+ instead of +"+.|oldreader-password "here_goesAquote:{backslash}""
oldreader-passwordfile|<path-to-file|""|A more secure alternative to the above, by storing your password elsewhere in your system.|oldreader-passwordfile "path-to-file"
oldreader-passwordfile|<path-to-file>|""|A more secure alternative to the above, by storing your password elsewhere in your system.|oldreader-passwordfile "path-to-file"
oldreader-passwordeval|<command>|""|Another secure alternative, is providing your password from an external command that is evaluated during login. This can be used to read your password from a gpg encrypted file or your system keyring.|oldreader-passwordeval "command some-parameter"
oldreader-show-special-feeds|[yes/no]|yes|If this is set, then "special feeds" like "People you follow" (articles shared by people you follow), "Starred items" (your starred articles) and "Shared items" (your shared articles) appear in your subscription list.|oldreader-show-special-feeds "no"
openbrowser-and-mark-jumps-to-next-unread|[yes/no]|no|If set to yes, jump to the next unread item when an item is opened in the browser and marked as read.|openbrowser-and-mark-jumps-to-next-unread yes
opml-url|<url> ...|""|If the OPML online subscription mode is enabled, then the list of feeds will be taken from the OPML file found on this location. Optionally, you can specify more than one URL. All the listed OPML URLs will then be taken into account when loading the feed list.|opml-url "http://host.domain.tld/blogroll.opml" "http://example.com/anotheropmlfile.opml"
Expand Down Expand Up @@ -107,7 +113,8 @@ ttrss-flag-star|<character>|""|If this is set and Tiny Tiny RSS support is used,
ttrss-login|<username>|""|Sets the username for use with Tiny Tiny RSS.|ttrss-login "admin"
ttrss-mode|[multi/single]|multi|Configures the mode in which Tiny Tiny RSS is used. In single-user mode, login and password are used for HTTP authentication, while in multi-user mode, they are used for authenticating with Tiny Tiny RSS.|ttrss-mode "single"
ttrss-password|<password>|""|Configures the password for use with Tiny Tiny RSS. Double quotes should be escaped, i.e. you should write +{backslash}"+ instead of +"+.|ttrss-password "here_goesAquote:{backslash}""
ttrss-passwordfile|<path-to-file|""|A more secure alternative to the above, by storing your password elsewhere in your system.|ttrss-passwordfile "path-to-file"
ttrss-passwordfile|<path-to-file>|""|A more secure alternative to the above, by storing your password elsewhere in your system.|ttrss-passwordfile "path-to-file"
ttrss-passwordeval|<command>|""|Another secure alternative, is providing your password from an external command that is evaluated during login. This can be used to read your password from a gpg encrypted file or your system keyring.|ttrss-passwordeval "command some-parameter"
ttrss-url|<url>|""|Configures the URL where the Tiny Tiny RSS installation you want to use resides.|ttrss-url "http://example.com/ttrss/"
unbind-key|<key> [<dialog>]|n/a|Unbind key <key>. This means that no operation is called when <key> is pressed. Optionally, you can specify a dialog (for a list of available dialogs, see "bind-key" above). If you specify one, the key binding will only be unbound for the specified dialog.|unbind-key R
urls-source|<source>|"local"|This configuration command sets the source where URLs shall be retrieved from. By default, this is ~/.newsbeuter/urls. Alternatively, you can set it to "opml", which enables newsbeuter's OPML online subscription mode, to "ttrss" which enables newsbeuter's Tiny Tiny RSS support, to "oldreader", which enables newsbeuter's The Old Reader support, to "newsblur", which enables NewsBlur support, or "feedhq" for FeedHQ support, or "ocnews" for ownCloud News support. Query feed specifications will be read from the local urls file regardless of this setting.|urls-source "oldreader"
Expand Down
88 changes: 85 additions & 3 deletions doc/example-config
Original file line number Diff line number Diff line change
Expand Up @@ -382,12 +382,24 @@
# A more secure alternative to the above, by storing your password elsewhere in
# your system.
#
# Syntax: <path-to-file
# Syntax: <path-to-file>
#
# Default value: ""
#
# feedhq-passwordfile "path-to-file"

#### feedhq-passwordeval
#
# Another secure alternative, is providing your password from an external
# command that is evaluated during login. This can be used to read your
# password from a gpg encrypted file or your system keyring.
#
# Syntax: <command>
#
# Default value: ""
#
# feedhq-passwordeval "command some-parameter"

#### feedhq-show-special-feeds
#
# If this is set, then "special feeds" like "People you follow" (articles
Expand Down Expand Up @@ -677,6 +689,29 @@
#
# newsblur-password "here_goesAquote:{backslash}""

#### newsblur-passwordfile
#
# A more secure alternative to the above, by storing your password elsewhere in
# your system.
#
# Syntax: <path-to-file>
#
# Default value: ""
#
# newsblur-passwordfile "path-to-file"

#### newsblur-passwordeval
#
# Another secure alternative, is providing your password from an external
# command that is evaluated during login. This can be used to read your
# password from a gpg encrypted file or your system keyring.
#
# Syntax: <command>
#
# Default value: ""
#
# newsblur-passwordeval "command some-parameter"

#### newsblur-url
#
# Configures the URL where the newsblur instance resides.
Expand Down Expand Up @@ -786,6 +821,29 @@
#
# ocnews-password "here_goesAquote:{backslash}""

#### ocnews-passwordfile
#
# A more secure alternative to the above, by storing your password elsewhere in
# your system.
#
# Syntax: <path-to-file>
#
# Default value: ""
#
# ocnews-passwordfile "path-to-file"

#### ocnews-passwordeval
#
# Another secure alternative, is providing your password from an external
# command that is evaluated during login. This can be used to read your
# password from a gpg encrypted file or your system keyring.
#
# Syntax: <command>
#
# Default value: ""
#
# ocnews-passwordeval "command some-parameter"

#### ocnews-url
#
# Configures the URL where the ownCloud instance resides.
Expand Down Expand Up @@ -869,12 +927,24 @@
# A more secure alternative to the above, by storing your password elsewhere in
# your system.
#
# Syntax: <path-to-file
# Syntax: <path-to-file>
#
# Default value: ""
#
# oldreader-passwordfile "path-to-file"

#### oldreader-passwordeval
#
# Another secure alternative, is providing your password from an external
# command that is evaluated during login. This can be used to read your
# password from a gpg encrypted file or your system keyring.
#
# Syntax: <command>
#
# Default value: ""
#
# oldreader-passwordeval "command some-parameter"

#### oldreader-show-special-feeds
#
# If this is set, then "special feeds" like "People you follow" (articles
Expand Down Expand Up @@ -1252,12 +1322,24 @@
# A more secure alternative to the above, by storing your password elsewhere in
# your system.
#
# Syntax: <path-to-file
# Syntax: <path-to-file>
#
# Default value: ""
#
# ttrss-passwordfile "path-to-file"

#### ttrss-passwordeval
#
# Another secure alternative, is providing your password from an external
# command that is evaluated during login. This can be used to read your
# password from a gpg encrypted file or your system keyring.
#
# Syntax: <command>
#
# Default value: ""
#
# ttrss-passwordeval "command some-parameter"

#### ttrss-url
#
# Configures the URL where the Tiny Tiny RSS installation you want to use
Expand Down
2 changes: 1 addition & 1 deletion include/newsblur_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class newsblur_api : public remote_api {
rsspp::feed fetch_feed(const std::string& id);
// TODO
private:
std::string retrieve_auth();
json_object * query_api(const std::string& url, const std::string* postdata);
std::map<std::string, std::vector<std::string>> mk_feeds_to_tags(json_object *);
std::string auth_info;
std::string api_location;
feedmap known_feeds;
unsigned int min_pages;
Expand Down
1 change: 1 addition & 0 deletions include/ocnews_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class ocnews_api : public remote_api {
rsspp::feed fetch_feed(const std::string& feed_id);
private:
typedef std::map<std::string, std::pair<rsspp::feed, long>> feedmap;
std::string retrieve_auth();
bool query(const std::string& query, json_object** result = nullptr, const std::string& post = "");
std::string md5(const std::string& str);
std::string auth;
Expand Down
8 changes: 8 additions & 0 deletions include/remote_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ namespace newsbeuter {

typedef std::pair<std::string, std::vector<std::string>> tagged_feedurl;

typedef struct {
std::string user;
std::string pass;
} credentials;

class remote_api {
public:
explicit remote_api(configcontainer * c) : cfg(c) { }
Expand All @@ -21,9 +26,12 @@ class remote_api {
virtual bool mark_all_read(const std::string& feedurl) = 0;
virtual bool mark_article_read(const std::string& guid, bool read) = 0;
virtual bool update_article_flags(const std::string& oldflags, const std::string& newflags, const std::string& guid) = 0;
static const std::string read_password(const std::string& file);
static const std::string eval_password(const std::string& cmd);
// TODO
protected:
configcontainer * cfg;
credentials get_credentials(const std::string& scope, const std::string& name);
};

}
Expand Down
5 changes: 5 additions & 0 deletions mk/mk.deps
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ src/reloadthread.o: src/reloadthread.cpp include/reloadthread.h \
filter/FilterParser.h include/utils.h include/logger.h config.h \
include/strprintf.h include/cache.h include/filtercontainer.h \
include/colormanager.h include/regexmanager.h include/remote_api.h
src/remote_api.o: src/remote_api.cpp include/remote_api.h \
include/configcontainer.h include/configparser.h include/utils.h \
include/logger.h config.h include/strprintf.h
src/rss.o: src/rss.cpp include/rss.h include/configcontainer.h \
include/configparser.h include/matcher.h filter/FilterParser.h \
include/utils.h include/logger.h config.h include/strprintf.h \
Expand Down Expand Up @@ -368,6 +371,8 @@ test/matcher.o: test/matcher.cpp test/catch.hpp include/matcher.h \
test/regexmanager.o: test/regexmanager.cpp test/catch.hpp \
include/regexmanager.h include/configparser.h include/matcher.h \
filter/FilterParser.h include/exceptions.h
test/remote_api.o: test/remote_api.cpp test/catch.hpp \
include/remote_api.h include/configcontainer.h include/configparser.h
test/rss.o: test/rss.cpp test/catch.hpp rss/rsspp.h include/remote_api.h \
include/configcontainer.h include/configparser.h rss/rsspp_internal.h \
include/rss.h include/matcher.h filter/FilterParser.h include/utils.h \
Expand Down
2 changes: 1 addition & 1 deletion mk/newsbeuter.deps
Original file line number Diff line number Diff line change
@@ -1 +1 @@
newsbeuter.cpp src/cache.cpp src/htmlrenderer.cpp src/urlreader.cpp src/logger.cpp src/view.cpp src/controller.cpp src/reloadthread.cpp src/tagsouppullparser.cpp src/downloadthread.cpp src/rss.cpp src/rss_parser.cpp src/formaction.cpp src/list_formaction.cpp src/feedlist_formaction.cpp src/itemlist_formaction.cpp src/itemview_formaction.cpp src/help_formaction.cpp src/filebrowser_formaction.cpp src/urlview_formaction.cpp src/select_formaction.cpp src/history.cpp src/filtercontainer.cpp src/listformatter.cpp src/regexmanager.cpp src/dialogs_formaction.cpp src/ttrss_api.cpp src/ttrss_urlreader.cpp src/newsblur_api.cpp src/newsblur_urlreader.cpp src/markreadthread.cpp src/oldreader_urlreader.cpp src/oldreader_api.cpp src/feedhq_api.cpp src/feedhq_urlreader.cpp src/textformatter.cpp src/ocnews_api.cpp src/ocnews_urlreader.cpp
newsbeuter.cpp src/cache.cpp src/htmlrenderer.cpp src/urlreader.cpp src/logger.cpp src/view.cpp src/controller.cpp src/reloadthread.cpp src/tagsouppullparser.cpp src/downloadthread.cpp src/rss.cpp src/rss_parser.cpp src/formaction.cpp src/list_formaction.cpp src/feedlist_formaction.cpp src/itemlist_formaction.cpp src/itemview_formaction.cpp src/help_formaction.cpp src/filebrowser_formaction.cpp src/urlview_formaction.cpp src/select_formaction.cpp src/history.cpp src/filtercontainer.cpp src/listformatter.cpp src/regexmanager.cpp src/dialogs_formaction.cpp src/ttrss_api.cpp src/ttrss_urlreader.cpp src/newsblur_api.cpp src/newsblur_urlreader.cpp src/markreadthread.cpp src/oldreader_urlreader.cpp src/oldreader_api.cpp src/feedhq_api.cpp src/feedhq_urlreader.cpp src/textformatter.cpp src/ocnews_api.cpp src/ocnews_urlreader.cpp src/remote_api.cpp
7 changes: 7 additions & 0 deletions src/configcontainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ configcontainer::configcontainer()
{ "feedhq-min-items", configdata("20", configdata_t::INT) },
{ "feedhq-password", configdata("", configdata_t::STR) },
{ "feedhq-passwordfile", configdata("", configdata_t::PATH) },
{ "feedhq-passwordeval", configdata("", configdata_t::STR) },
{ "feedhq-show-special-feeds", configdata("true", configdata_t::BOOL) },
{ "feedhq-url", configdata("https://feedhq.org/", configdata_t::STR) },
{ "feedlist-format", configdata("%4i %n %11u %t", configdata_t::STR) },
Expand All @@ -75,6 +76,8 @@ configcontainer::configcontainer()
{ "newsblur-login", configdata("", configdata_t::STR) },
{ "newsblur-min-items", configdata("20", configdata_t::INT) },
{ "newsblur-password", configdata("", configdata_t::STR) },
{ "newsblur-passwordfile", configdata("", configdata_t::PATH) },
{ "newsblur-passwordeval", configdata("", configdata_t::STR) },
{ "newsblur-url",
configdata("https://newsblur.com", configdata_t::STR) },
{ "notify-always", configdata("no", configdata_t::BOOL) },
Expand All @@ -93,6 +96,7 @@ configcontainer::configcontainer()
{ "oldreader-min-items", configdata("20", configdata_t::INT) },
{ "oldreader-password", configdata("", configdata_t::STR) },
{ "oldreader-passwordfile", configdata("", configdata_t::PATH) },
{ "oldreader-passwordeval", configdata("", configdata_t::STR) },
{ "oldreader-show-special-feeds",
configdata("true", configdata_t::BOOL) },
{ "openbrowser-and-mark-jumps-to-next-unread",
Expand Down Expand Up @@ -135,9 +139,12 @@ configcontainer::configcontainer()
"single", "multi" })) },
{ "ttrss-password", configdata("", configdata_t::STR) },
{ "ttrss-passwordfile", configdata("", configdata_t::PATH) },
{ "ttrss-passwordeval", configdata("", configdata_t::STR) },
{ "ttrss-url", configdata("", configdata_t::STR) },
{ "ocnews-login", configdata("", configdata_t::STR) },
{ "ocnews-password", configdata("", configdata_t::STR) },
{ "ocnews-passwordfile", configdata("", configdata_t::PATH) },
{ "ocnews-passwordeval", configdata("", configdata_t::STR) },
{ "ocnews-flag-star", configdata("", configdata_t::STR) },
{ "ocnews-url", configdata("", configdata_t::STR) },
{ "ocnews-verifyhost",
Expand Down
Loading

0 comments on commit 112fb35

Please sign in to comment.