Release v2.20.1: migrate authentication to Better Auth
This commit is contained in:
1 parent
e9a53f577c
commit
fba4f99ff7
92 files changed
+5085
-1943
No files matched your search
@@ -9,7 +9,7 @@ const { WebSocket } = require('ws');
|
||||
|
||||
require('../src/common');
|
||||
|
||||
const { hashPassword } = require('../src/auth');
|
||||
const { hashScryptPassword } = require('../src/auth');
|
||||
const { createLocalControlService } = require('../src/player/local-control');
|
||||
|
||||
async function createTestService(options) {
|
||||
@@ -52,15 +52,13 @@ test('local control leaves cached player media available to the static media rou
|
||||
|
||||
test('local control authenticates only cached eligible users and scopes commands to local runtime', async () => {
|
||||
const { app, service, temporaryDirectory } = await createTestService();
|
||||
const password = hashPassword('CorrectHorseBatteryStaple!');
|
||||
const password = await hashScryptPassword('CorrectHorseBatteryStaple!');
|
||||
await service.saveUsers([{
|
||||
id: 7,
|
||||
name: 'Operator',
|
||||
username: 'operator',
|
||||
email: 'operator@example.com',
|
||||
password_hash: password.hash,
|
||||
password_salt: password.salt,
|
||||
password_iterations: password.iterations
|
||||
password_hash: password
|
||||
}]);
|
||||
await service.loadCache();
|
||||
|
||||
@@ -69,7 +67,8 @@ test('local control authenticates only cached eligible users and scopes commands
|
||||
assert.equal(cachedUsers[0].name, undefined);
|
||||
assert.equal(cachedUsers[0].email, undefined);
|
||||
assert.equal(cachedUsers[0].username, undefined);
|
||||
assert.equal(cachedUsers[0].password_iterations, undefined);
|
||||
assert.equal(cachedUsers[0].password_hash, password);
|
||||
assert.equal(cachedUsers[0].password_salt, undefined);
|
||||
const server = app.listen(0);
|
||||
try {
|
||||
const address = server.address();
|
||||
@@ -126,14 +125,12 @@ test('local control authenticates only cached eligible users and scopes commands
|
||||
|
||||
test('local control refuses login when the cached authorization is stale', async () => {
|
||||
const { app, service, temporaryDirectory } = await createTestService({ cacheMaxAgeMs: 1 });
|
||||
const password = hashPassword('CorrectHorseBatteryStaple!');
|
||||
const password = await hashScryptPassword('CorrectHorseBatteryStaple!');
|
||||
await service.saveUsers([{
|
||||
id: 7,
|
||||
name: 'Operator',
|
||||
username: 'operator',
|
||||
password_hash: password.hash,
|
||||
password_salt: password.salt,
|
||||
password_iterations: password.iterations
|
||||
password_hash: password
|
||||
}]);
|
||||
await service.loadCache();
|
||||
await new Promise(function (resolve) { setTimeout(resolve, 5); });
|
||||
@@ -155,11 +152,10 @@ test('local control refuses login when the cached authorization is stale', async
|
||||
|
||||
test('local control throttles repeated failed logins', async () => {
|
||||
const { app, service, temporaryDirectory } = await createTestService({ loginRateLimitMaxAttempts: 2, loginRateLimitWindowMs: 60 * 1000 });
|
||||
const password = hashPassword('CorrectHorseBatteryStaple!');
|
||||
const password = await hashScryptPassword('CorrectHorseBatteryStaple!');
|
||||
await service.saveUsers([{
|
||||
username: 'operator',
|
||||
password_hash: password.hash,
|
||||
password_salt: password.salt
|
||||
password_hash: password
|
||||
}]);
|
||||
await service.loadCache();
|
||||
|
||||
@@ -186,11 +182,10 @@ test('local control throttles repeated failed logins', async () => {
|
||||
|
||||
test('local control closes live sockets when authorization is revoked', async () => {
|
||||
const { server, service, temporaryDirectory } = await createTestService();
|
||||
const password = hashPassword('CorrectHorseBatteryStaple!');
|
||||
const password = await hashScryptPassword('CorrectHorseBatteryStaple!');
|
||||
await service.saveUsers([{
|
||||
username: 'operator',
|
||||
password_hash: password.hash,
|
||||
password_salt: password.salt
|
||||
password_hash: password
|
||||
}]);
|
||||
await service.loadCache();
|
||||
|
||||
|
||||
Reference in new issue
Block a user