Skip to content

Commit fe48310

Browse files
authored
🔀 Merge pull request #113 from Lissy93/FIX/auth-security-fix
[SECURITY] Improve Robustness of Auth Checking
2 parents 01e4c0f + 87f6438 commit fe48310

File tree

5 files changed

+20
-5
lines changed

5 files changed

+20
-5
lines changed

.github/CHANGELOG.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Changelog
22

3-
## ✨ 1.4.8 - Optional Crash Reports [PR #120](https://github.com/Lissy93/dashy/pull/112)
3+
## 🔒 1.5.0 - Improve Robustness of Auth [PR #113](https://github.com/Lissy93/dashy/pull/113)
4+
- Use both username + password for generating token, so that a change in either will log the user out
5+
- Prevent privilege escalation by disallowing a user from modifying their user type through the UI
6+
- Improve the isAuthenticated check, by taking account of empty users array
7+
8+
## ✨ 1.4.8 - Optional Crash Reports [PR #112](https://github.com/Lissy93/dashy/pull/112)
49
- Adds an optional, off by default method of getting crash reports
510
- This can be enabled in `appConfig.enableErrorReporting`, and will not be used at all unless explicitly activated by user
611
- This is needed for when a user raises a bug which is hard to fix

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Dashy",
3-
"version": "1.4.8",
3+
"version": "1.5.0",
44
"license": "MIT",
55
"main": "server",
66
"scripts": {

src/components/Configuration/JsonEditor.vue

+1
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ export default {
146146
localStorage.setItem(localStorageKeys.PAGE_INFO, JSON.stringify(data.pageInfo));
147147
}
148148
if (data.appConfig) {
149+
data.appConfig.auth = this.config.appConfig.auth || [];
149150
localStorage.setItem(localStorageKeys.APP_CONFIG, JSON.stringify(data.appConfig));
150151
}
151152
if (data.appConfig.theme) {

src/router.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,14 @@ import { metaTagData } from '@/utils/defaults';
1111

1212
Vue.use(Router);
1313

14+
/**
15+
* Checks if the current user is either authenticated,
16+
* or if authentication is not enabled
17+
* @returns true if user logged in, or user management not enabled
18+
*/
1419
const isAuthenticated = () => {
1520
const users = config.appConfig.auth;
16-
return (!users || isLoggedIn(users));
21+
return (!users || users.length === 0 || isLoggedIn(users));
1722
};
1823

1924
const router = new Router({

src/utils/Auth.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ import { cookieKeys, localStorageKeys } from './defaults';
66
* @param {String} user The username of user
77
* @returns {String} The hashed token
88
*/
9-
const generateUserToken = (user) => sha256(user.toString()).toString().toLowerCase();
9+
const generateUserToken = (user) => {
10+
const strAndUpper = (input) => input.toString().toUpperCase();
11+
const sha = sha256(strAndUpper(user.user) + strAndUpper(user.hash));
12+
return strAndUpper(sha);
13+
};
1014

1115
/**
1216
* Checks if the user is currently authenticated
@@ -47,7 +51,7 @@ export const checkCredentials = (username, pass, users) => {
4751
response = { correct: false, msg: 'Missing Password' };
4852
} else {
4953
users.forEach((user) => {
50-
if (user.user === username) {
54+
if (user.user.toLowerCase() === username.toLowerCase()) {
5155
if (user.hash.toLowerCase() === sha256(pass).toString().toLowerCase()) {
5256
response = { correct: true, msg: 'Logging in...' };
5357
} else {

0 commit comments

Comments
 (0)