Subsonic API: added a way to disable the user/password authentication method (enabled by default)
This commit is contained in:
@@ -88,9 +88,11 @@
|
|||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<label class="form-label" for="${id:subsonic-token}">
|
<label class="form-label" for="${id:subsonic-token}">
|
||||||
${tr:Lms.Settings.subsonic-token}
|
${tr:Lms.Settings.subsonic-token}
|
||||||
<button type="button" class="btn btn-sm p-0" data-bs-toggle="tooltip" data-bs-placement="right" title="${block:Lms.Settings.subsonic-token-usage}">
|
${<if-has-subsonic-token-usage>}
|
||||||
|
<button type="button" class="btn btn-sm p-0" data-bs-toggle="tooltip" data-bs-placement="right" title="${tr:Lms.Settings.subsonic-token-usage}">
|
||||||
<i class="fa fa-fw fa-info-circle" aria-hidden="true"></i>
|
<i class="fa fa-fw fa-info-circle" aria-hidden="true"></i>
|
||||||
</button>
|
</button>
|
||||||
|
${</if-has-subsonic-token-usage>}
|
||||||
</label>
|
</label>
|
||||||
<div class="input-group mb-3">
|
<div class="input-group mb-3">
|
||||||
${subsonic-token-regen-btn class="btn btn-outline-secondary"}
|
${subsonic-token-regen-btn class="btn btn-outline-secondary"}
|
||||||
|
|||||||
@@ -68,6 +68,10 @@ login-throttler-max-entries = 10000;
|
|||||||
# API
|
# API
|
||||||
api-subsonic = true;
|
api-subsonic = true;
|
||||||
|
|
||||||
|
# Enable or disable user/password authentication for the Subsonic API.
|
||||||
|
# Note: Since token/salt authentication is always disabled, setting this to 'false' means only API keys can be used to access the Subsonic API.
|
||||||
|
api-subsonic-support-user-password-auth = true;
|
||||||
|
|
||||||
# Use this list to make the reported server version to 1.12.0 depending on the client's name
|
# Use this list to make the reported server version to 1.12.0 depending on the client's name
|
||||||
# Main usage is to make auto detections for the 'p' (password) parameter work
|
# Main usage is to make auto detections for the 'p' (password) parameter work
|
||||||
api-subsonic-old-server-protocol-clients = ("DSub");
|
api-subsonic-old-server-protocol-clients = ("DSub");
|
||||||
|
|||||||
@@ -298,6 +298,7 @@ namespace lms::api::subsonic
|
|||||||
: _serverProtocolVersionsByClient{ readConfigProtocolVersions() }
|
: _serverProtocolVersionsByClient{ readConfigProtocolVersions() }
|
||||||
, _openSubsonicDisabledClients{ readOpenSubsonicDisabledClients() }
|
, _openSubsonicDisabledClients{ readOpenSubsonicDisabledClients() }
|
||||||
, _defaultReleaseCoverClients{ readDefaultCoverClients() }
|
, _defaultReleaseCoverClients{ readDefaultCoverClients() }
|
||||||
|
, _supportUserPasswordAuthentication{ core::Service<core::IConfig>::get()->getBool("api-subsonic-support-user-password-auth", true) }
|
||||||
, _db{ db }
|
, _db{ db }
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -451,6 +452,9 @@ namespace lms::api::subsonic
|
|||||||
|
|
||||||
const auto user{ getParameterAs<std::string>(parameters, "u") };
|
const auto user{ getParameterAs<std::string>(parameters, "u") };
|
||||||
const auto password{ getParameterAs<std::string>(parameters, "p") };
|
const auto password{ getParameterAs<std::string>(parameters, "p") };
|
||||||
|
if (!_supportUserPasswordAuthentication && (password || user))
|
||||||
|
throw ProvidedAuthenticationMechanismNotSupportedError{};
|
||||||
|
|
||||||
const auto apiKey{ getParameterAs<std::string>(parameters, "apiKey") };
|
const auto apiKey{ getParameterAs<std::string>(parameters, "apiKey") };
|
||||||
|
|
||||||
if (user && !password)
|
if (user && !password)
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ namespace lms::api::subsonic
|
|||||||
const std::unordered_map<std::string, ProtocolVersion> _serverProtocolVersionsByClient;
|
const std::unordered_map<std::string, ProtocolVersion> _serverProtocolVersionsByClient;
|
||||||
const std::unordered_set<std::string> _openSubsonicDisabledClients;
|
const std::unordered_set<std::string> _openSubsonicDisabledClients;
|
||||||
const std::unordered_set<std::string> _defaultReleaseCoverClients;
|
const std::unordered_set<std::string> _defaultReleaseCoverClients;
|
||||||
|
const bool _supportUserPasswordAuthentication;
|
||||||
|
|
||||||
db::Db& _db;
|
db::Db& _db;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -557,6 +557,7 @@ namespace lms::ui
|
|||||||
// Subsonic
|
// Subsonic
|
||||||
{
|
{
|
||||||
t->setCondition("if-has-subsonic-api", core::Service<core::IConfig>::get()->getBool("api-subsonic", true));
|
t->setCondition("if-has-subsonic-api", core::Service<core::IConfig>::get()->getBool("api-subsonic", true));
|
||||||
|
t->setCondition("if-has-subsonic-token-usage", core::Service<core::IConfig>::get()->getBool("api-subsonic-support-user-password-auth", true));
|
||||||
|
|
||||||
auto subsonicToken{ std::make_unique<Wt::WLineEdit>() };
|
auto subsonicToken{ std::make_unique<Wt::WLineEdit>() };
|
||||||
Wt::WLineEdit* subsonicTokenPtr{ subsonicToken.get() };
|
Wt::WLineEdit* subsonicTokenPtr{ subsonicToken.get() };
|
||||||
|
|||||||
Reference in New Issue
Block a user