mirror of
https://github.com/OutlineFoundation/outline-server.git
synced 2026-08-04 14:37:34 +00:00
fix(server): the provided password must use unique value (#1506)
This commit is contained in:
parent
9779f5dc5f
commit
ceca3d617c
3 changed files with 27 additions and 0 deletions
|
|
@ -52,3 +52,11 @@ export class AccessKeyConflict extends OutlineError {
|
|||
super(`Access key "${accessKeyId}" conflict`);
|
||||
}
|
||||
}
|
||||
|
||||
export class PasswordConflict extends OutlineError {
|
||||
constructor(accessKeyId?: AccessKeyId) {
|
||||
super(
|
||||
`Access key ${accessKeyId} has the same password. Please specify a unique password for each access key`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,6 +81,16 @@ describe('ServerAccessKeyRepository', () => {
|
|||
done();
|
||||
});
|
||||
|
||||
it('createNewAccessKey throws on creating keys with existing passwords', async (done) => {
|
||||
const repo = new RepoBuilder().build();
|
||||
await repo.createNewAccessKey({password: 'P@$$w0rd'});
|
||||
await expectAsyncThrow(
|
||||
repo.createNewAccessKey.bind(repo, {password: 'P@$$w0rd'}),
|
||||
errors.PasswordConflict
|
||||
);
|
||||
done();
|
||||
});
|
||||
|
||||
it('New access keys have the correct default encryption method', (done) => {
|
||||
const repo = new RepoBuilder().build();
|
||||
repo.createNewAccessKey().then((accessKey) => {
|
||||
|
|
|
|||
|
|
@ -204,6 +204,15 @@ export class ServerAccessKeyRepository implements AccessKeyRepository {
|
|||
} else {
|
||||
id = this.generateId();
|
||||
}
|
||||
|
||||
const isPasswordConflict = this.listAccessKeys().some(
|
||||
(accessKey) => accessKey.proxyParams.password == params?.password
|
||||
);
|
||||
|
||||
if (isPasswordConflict) {
|
||||
throw new errors.PasswordConflict(id);
|
||||
}
|
||||
|
||||
const metricsId = uuidv4();
|
||||
const password = params?.password ?? generatePassword();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue