Skip to content
This repository has been archived by the owner on Aug 23, 2024. It is now read-only.

Encode subsonic plaintext passwords when using them in api calls #452

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const getAuth = (useLegacyAuth: boolean) => {
return {
username: localStorage.getItem('username') || '',
password: localStorage.getItem('password') || '',
passwordEncoded: localStorage.getItem('passwordEncoded') || '',
server: localStorage.getItem('server') || '',
};
}
Expand Down Expand Up @@ -100,7 +101,7 @@ const getCoverArtUrl = (item: any, useLegacyAuth: boolean, size?: number) => {
`${API_BASE_URL}/getCoverArt.view` +
`?id=${item.coverArt}` +
`&u=${auth.username}` +
`&p=${auth.password}` +
`&p=${auth.passwordEncoded}` +
`&v=1.13.0` +
`&c=sonixd` +
`${size ? `&size=${size}` : ''}`
Expand All @@ -125,7 +126,7 @@ export const getDownloadUrl = (options: { id: string }, useLegacyAuth = legacyAu
`${API_BASE_URL}/download.view` +
`?id=${options.id}` +
`&u=${auth.username}` +
`&p=${auth.password}` +
`&p=${auth.passwordEncoded}` +
`&v=1.13.0` +
`&c=sonixd`
);
Expand All @@ -148,7 +149,7 @@ const getStreamUrl = (id: string, useLegacyAuth: boolean) => {
`${API_BASE_URL}/stream.view` +
`?id=${id}` +
`&u=${auth.username}` +
`&p=${auth.password}` +
`&p=${auth.passwordEncoded}` +
`&v=1.13.0` +
`&c=sonixd`
);
Expand Down
3 changes: 2 additions & 1 deletion src/components/settings/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
try {
const testConnection = legacyAuth
? await axios.get(
`${cleanServerName}/rest/ping.view?v=1.13.0&c=sonixd&f=json&u=${userName}&p=${password}`
`${cleanServerName}/rest/ping.view?v=1.13.0&c=sonixd&f=json&u=${userName}&p=${encodeURIComponent(password)}`

Check failure on line 41 in src/components/settings/Login.tsx

View workflow job for this annotation

GitHub Actions / release (ubuntu-latest)

Replace `password` with `⏎··············password⏎············`
)
: await axios.get(
`${cleanServerName}/rest/ping.view?v=1.13.0&c=sonixd&f=json&u=${userName}&s=${salt}&t=${hash}`
Expand All @@ -64,6 +64,7 @@
localStorage.setItem('serverType', 'subsonic');
localStorage.setItem('username', userName);
localStorage.setItem('password', password);
localStorage.setItem('passwordEncoded', encodeURIComponent(password));
localStorage.setItem('salt', salt);
localStorage.setItem('hash', hash);

Expand Down
Loading