Subsonic API: removed useless auth

This commit is contained in:
emeric
2023-11-11 23:45:03 +01:00
parent 6d50783511
commit 07949de20f
+16 -3
View File
@@ -300,13 +300,13 @@ namespace API::Subsonic
const ResponseFormat format{ getParameterAs<std::string>(request.getParameterMap(), "f").value_or("xml") == "json" ? ResponseFormat::json : ResponseFormat::xml }; const ResponseFormat format{ getParameterAs<std::string>(request.getParameterMap(), "f").value_or("xml") == "json" ? ResponseFormat::json : ResponseFormat::xml };
ProtocolVersion protocolVersion{ defaultServerProtocolVersion }; ProtocolVersion protocolVersion{ defaultServerProtocolVersion };
try try
{ {
// We need to parse client a soon as possible to make sure to answer with the right protocol version // We need to parse client a soon as possible to make sure to answer with the right protocol version
protocolVersion = getServerProtocolVersion(getMandatoryParameterAs<std::string>(request.getParameterMap(), "c")); protocolVersion = getServerProtocolVersion(getMandatoryParameterAs<std::string>(request.getParameterMap(), "c"));
RequestContext requestContext{ buildRequestContext(request) }; RequestContext requestContext{ buildRequestContext(request) };
auto itEntryPoint{ requestEntryPoints.find(requestPath) }; auto itEntryPoint{ requestEntryPoints.find(requestPath) };
if (itEntryPoint != requestEntryPoints.end()) if (itEntryPoint != requestEntryPoints.end())
{ {
@@ -399,6 +399,19 @@ namespace API::Subsonic
Database::UserId SubsonicResource::authenticateUser(const Wt::Http::Request& request, const ClientInfo& clientInfo) Database::UserId SubsonicResource::authenticateUser(const Wt::Http::Request& request, const ClientInfo& clientInfo)
{ {
// if the request if a continuation, the user is already authenticated
if (request.continuation())
{
Database::Session& session{ _db.getTLSSession() };
auto transaction{ session.createSharedTransaction() };
const auto user{ Database::User::find(session, clientInfo.user) };
if (!user)
throw UserNotAuthorizedError{};
return user->getId();
}
if (auto * authEnvService{ Service<::Auth::IEnvService>::get() }) if (auto * authEnvService{ Service<::Auth::IEnvService>::get() })
{ {
const auto checkResult{ authEnvService->processRequest(request) }; const auto checkResult{ authEnvService->processRequest(request) };
@@ -423,7 +436,7 @@ namespace API::Subsonic
} }
} }
throw InternalErrorGenericError{ "No service avalaible to authenticate user" }; throw InternalErrorGenericError{ "No service available to authenticate user" };
} }
} // namespace api::subsonic } // namespace api::subsonic