Subsonic API: report error 41 for auth token attempts
This commit is contained in:
@@ -80,5 +80,12 @@ namespace API::Subsonic
|
||||
|
||||
return *res;
|
||||
}
|
||||
|
||||
inline
|
||||
bool
|
||||
hasParameter(const Wt::Http::ParameterMap& parameterMap, const std::string& param)
|
||||
{
|
||||
return parameterMap.find(param) != std::cend(parameterMap);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2114,6 +2114,9 @@ SubsonicResource::getClientInfo(const Wt::Http::ParameterMap& parameters)
|
||||
{
|
||||
ClientInfo res;
|
||||
|
||||
if (hasParameter(parameters, "t"))
|
||||
throw TokenAuthenticationNotSupportedForLDAPUsersError {};
|
||||
|
||||
// Mandatory parameters
|
||||
res.name = getMandatoryParameterAs<std::string>(parameters, "c");
|
||||
res.version = getMandatoryParameterAs<ProtocolVersion>(parameters, "v");
|
||||
|
||||
@@ -48,6 +48,7 @@ class Error
|
||||
ClientMustUpgrade = 20,
|
||||
ServerMustUpgrade = 30,
|
||||
WrongUsernameOrPassword = 40,
|
||||
TokenAuthenticationNotSupportedForLDAPUsers = 41,
|
||||
UserNotAuthorized = 50,
|
||||
RequestedDataNotFound = 70,
|
||||
};
|
||||
@@ -105,6 +106,14 @@ class WrongUsernameOrPasswordError : public Error
|
||||
std::string getMessage() const override { return "Wrong username or password."; }
|
||||
};
|
||||
|
||||
class TokenAuthenticationNotSupportedForLDAPUsersError : public Error
|
||||
{
|
||||
public:
|
||||
TokenAuthenticationNotSupportedForLDAPUsersError() : Error {Code::TokenAuthenticationNotSupportedForLDAPUsers} {}
|
||||
private:
|
||||
std::string getMessage() const override { return "Token authentication not supported for LDAP users."; }
|
||||
};
|
||||
|
||||
class UserNotAuthorizedError : public Error
|
||||
{
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user