mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 18:03:33 +00:00
Add a basic form of unsecure authentication (in plain password)
This commit is contained in:
parent
e5aec08c8e
commit
d93c3bb45c
8 changed files with 44 additions and 9 deletions
|
|
@ -54,6 +54,7 @@ public class App extends Application {
|
||||||
SubsonicPreferences preferences = new SubsonicPreferences();
|
SubsonicPreferences preferences = new SubsonicPreferences();
|
||||||
preferences.setServerUrl(server);
|
preferences.setServerUrl(server);
|
||||||
preferences.setUsername(username);
|
preferences.setUsername(username);
|
||||||
|
preferences.setPassword(password);
|
||||||
preferences.setAuthentication(password, token, salt);
|
preferences.setAuthentication(password, token, salt);
|
||||||
|
|
||||||
return new Subsonic(context, preferences);
|
return new Subsonic(context, preferences);
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,9 @@ import com.cappielloantonio.play.model.Server;
|
||||||
|
|
||||||
@SuppressLint("RestrictedApi")
|
@SuppressLint("RestrictedApi")
|
||||||
@Database(
|
@Database(
|
||||||
version = 30,
|
version = 31,
|
||||||
entities = {Queue.class, Server.class, RecentSearch.class, Download.class, Playlist.class},
|
entities = {Queue.class, Server.class, RecentSearch.class, Download.class, Playlist.class},
|
||||||
autoMigrations = { @AutoMigration(from = 29, to = 30) }
|
autoMigrations = { @AutoMigration(from = 30, to = 31) }
|
||||||
)
|
)
|
||||||
public abstract class AppDatabase extends RoomDatabase {
|
public abstract class AppDatabase extends RoomDatabase {
|
||||||
private static final String TAG = "AppDatabase";
|
private static final String TAG = "AppDatabase";
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,10 @@ public class Server implements Parcelable {
|
||||||
@ColumnInfo(name = "timestamp")
|
@ColumnInfo(name = "timestamp")
|
||||||
private long timestamp;
|
private long timestamp;
|
||||||
|
|
||||||
public Server(@NonNull String serverId, String serverName, String username, String address, String token, String salt, long timestamp) {
|
@ColumnInfo(name = "low_security", defaultValue = "false")
|
||||||
|
private boolean lowSecurity;
|
||||||
|
|
||||||
|
public Server(@NonNull String serverId, String serverName, String username, String address, String token, String salt, long timestamp, boolean lowSecurity) {
|
||||||
this.serverId = serverId;
|
this.serverId = serverId;
|
||||||
this.serverName = serverName;
|
this.serverName = serverName;
|
||||||
this.username = username;
|
this.username = username;
|
||||||
|
|
@ -41,6 +44,7 @@ public class Server implements Parcelable {
|
||||||
this.token = token;
|
this.token = token;
|
||||||
this.salt = salt;
|
this.salt = salt;
|
||||||
this.timestamp = timestamp;
|
this.timestamp = timestamp;
|
||||||
|
this.lowSecurity = lowSecurity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
|
@ -100,6 +104,14 @@ public class Server implements Parcelable {
|
||||||
this.timestamp = timestamp;
|
this.timestamp = timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isLowSecurity() {
|
||||||
|
return lowSecurity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLowSecurity(boolean lowSecurity) {
|
||||||
|
this.lowSecurity = lowSecurity;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ public class Subsonic {
|
||||||
public String getUrl() {
|
public String getUrl() {
|
||||||
String url = preferences.getServerUrl() + "/rest/";
|
String url = preferences.getServerUrl() + "/rest/";
|
||||||
|
|
||||||
return url.replace("//rest","/rest");
|
return url.replace("//rest", "/rest");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, String> getParams() {
|
public Map<String, String> getParams() {
|
||||||
|
|
@ -112,6 +112,8 @@ public class Subsonic {
|
||||||
params.put("c", preferences.getClientName());
|
params.put("c", preferences.getClientName());
|
||||||
params.put("f", "xml");
|
params.put("f", "xml");
|
||||||
|
|
||||||
|
if (preferences.getPassword() != null && !preferences.getPassword().trim().equals("")) params.put("p", preferences.getPassword());
|
||||||
|
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import java.util.UUID;
|
||||||
public class SubsonicPreferences {
|
public class SubsonicPreferences {
|
||||||
private String serverUrl;
|
private String serverUrl;
|
||||||
private String username;
|
private String username;
|
||||||
|
private String password;
|
||||||
private String clientName = "Play";
|
private String clientName = "Play";
|
||||||
private SubsonicAuthentication authentication;
|
private SubsonicAuthentication authentication;
|
||||||
|
|
||||||
|
|
@ -18,6 +19,10 @@ public class SubsonicPreferences {
|
||||||
return username;
|
return username;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
public String getClientName() {
|
public String getClientName() {
|
||||||
return clientName;
|
return clientName;
|
||||||
}
|
}
|
||||||
|
|
@ -34,6 +39,10 @@ public class SubsonicPreferences {
|
||||||
this.username = username;
|
this.username = username;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
public void setClientName(String clientName) {
|
public void setClientName(String clientName) {
|
||||||
this.clientName = clientName;
|
this.clientName = clientName;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ public class ServerSignupDialog extends DialogFragment {
|
||||||
private String password;
|
private String password;
|
||||||
private String server;
|
private String server;
|
||||||
private boolean directAccess = false;
|
private boolean directAccess = false;
|
||||||
|
private boolean lowSecurity = false;
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -90,7 +91,10 @@ public class ServerSignupDialog extends DialogFragment {
|
||||||
bind.passwordTextView.setText("");
|
bind.passwordTextView.setText("");
|
||||||
bind.serverTextView.setText(loginViewModel.getServerToEdit().getAddress());
|
bind.serverTextView.setText(loginViewModel.getServerToEdit().getAddress());
|
||||||
bind.directAccessCheckbox.setChecked(false);
|
bind.directAccessCheckbox.setChecked(false);
|
||||||
|
bind.lowSecurityCheckbox.setChecked(loginViewModel.getServerToEdit().isLowSecurity());
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
loginViewModel.setServerToEdit(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -115,6 +119,7 @@ public class ServerSignupDialog extends DialogFragment {
|
||||||
password = Objects.requireNonNull(bind.passwordTextView.getText()).toString();
|
password = Objects.requireNonNull(bind.passwordTextView.getText()).toString();
|
||||||
server = Objects.requireNonNull(bind.serverTextView.getText()).toString().trim();
|
server = Objects.requireNonNull(bind.serverTextView.getText()).toString().trim();
|
||||||
directAccess = bind.directAccessCheckbox.isChecked();
|
directAccess = bind.directAccessCheckbox.isChecked();
|
||||||
|
lowSecurity = bind.lowSecurityCheckbox.isChecked();
|
||||||
|
|
||||||
if (TextUtils.isEmpty(serverName)) {
|
if (TextUtils.isEmpty(serverName)) {
|
||||||
bind.serverNameTextView.setError(getString(R.string.error_required));
|
bind.serverNameTextView.setError(getString(R.string.error_required));
|
||||||
|
|
@ -162,14 +167,13 @@ public class ServerSignupDialog extends DialogFragment {
|
||||||
if (token != null && salt != null) {
|
if (token != null && salt != null) {
|
||||||
String serverID = loginViewModel.getServerToEdit() != null ? loginViewModel.getServerToEdit().getServerId() : UUID.randomUUID().toString();
|
String serverID = loginViewModel.getServerToEdit() != null ? loginViewModel.getServerToEdit().getServerId() : UUID.randomUUID().toString();
|
||||||
|
|
||||||
PreferenceUtil.getInstance(context).setPassword(null);
|
|
||||||
PreferenceUtil.getInstance(context).setToken(token);
|
PreferenceUtil.getInstance(context).setToken(token);
|
||||||
PreferenceUtil.getInstance(context).setSalt(salt);
|
PreferenceUtil.getInstance(context).setSalt(salt);
|
||||||
PreferenceUtil.getInstance(context).setServerId(serverID);
|
PreferenceUtil.getInstance(context).setServerId(serverID);
|
||||||
|
|
||||||
loginViewModel.addServer(new Server(serverID, this.serverName, this.username, this.server, token, salt, System.currentTimeMillis()));
|
if (!lowSecurity) PreferenceUtil.getInstance(context).setPassword(null);
|
||||||
|
|
||||||
return;
|
loginViewModel.addServer(new Server(serverID, this.serverName, this.username, this.server, token, salt, System.currentTimeMillis(), this.lowSecurity));
|
||||||
}
|
}
|
||||||
|
|
||||||
App.getSubsonicClientInstance(context, true);
|
App.getSubsonicClientInstance(context, true);
|
||||||
|
|
|
||||||
|
|
@ -60,8 +60,6 @@
|
||||||
app:endIconTint="?android:textColorSecondary"
|
app:endIconTint="?android:textColorSecondary"
|
||||||
app:errorEnabled="true">
|
app:errorEnabled="true">
|
||||||
|
|
||||||
<!-- Navidrome android:text="!$4EBXhSPUi4$E#oagvAisCA" -->
|
|
||||||
<!-- Gonic android:text="hYP3%yD!rx@GBf95B2wbRUk8" -->
|
|
||||||
<com.google.android.material.textfield.TextInputEditText
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
android:id="@+id/password_text_view"
|
android:id="@+id/password_text_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
@ -101,4 +99,12 @@
|
||||||
android:layout_marginStart="24dp"
|
android:layout_marginStart="24dp"
|
||||||
android:layout_marginEnd="24dp"
|
android:layout_marginEnd="24dp"
|
||||||
android:text="@string/server_signup_dialog_action_direct_access"/>
|
android:text="@string/server_signup_dialog_action_direct_access"/>
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/low_security_checkbox"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="24dp"
|
||||||
|
android:layout_marginEnd="24dp"
|
||||||
|
android:text="@string/server_signup_dialog_action_low_security"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
@ -198,4 +198,5 @@
|
||||||
<string name="starred_sync_dialog_title">Sync starred tracks</string>
|
<string name="starred_sync_dialog_title">Sync starred tracks</string>
|
||||||
<string name="settings_title_transcoding">Transcoding</string>
|
<string name="settings_title_transcoding">Transcoding</string>
|
||||||
<string name="settings_summary_transcoding">Priority given to the transcoding mode. If set to \"Direct play\" the bitrate of the file will not be changed.</string>
|
<string name="settings_summary_transcoding">Priority given to the transcoding mode. If set to \"Direct play\" the bitrate of the file will not be changed.</string>
|
||||||
|
<string name="server_signup_dialog_action_low_security">Low security</string>
|
||||||
</resources>
|
</resources>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue