-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add password protection to templates * test: add tests * fix/test: add tests, make fixes * fix: backbone API * feat: change error message * refactor: nameof, toString * feat/test: error message, add validation test * fix: remove only * chore: bump backbone Co-authored-by: Julian König <[email protected]> * fix: missing password pass * refactor: wrong variable name * refactor: review comments * chore: upgrade backbone and adapt client * feat: add password-protection to tokens * test: add anonymous tests * fix: pass password * fix: error in test * chore: build schemas * feat: hash passwords * feat: add separate pin * feat: enhance password type * refactor: align error messages * fix: more enhancing password type * test: adapt tests * test: reference adaptations * wip * refactor/feat: review comments * feat: add transport empty string validation * test: add tests * fix: schemas, error codes * fix: add PINs when loading * feat: add loading validation, tests * test: add validations * fix: test errors * fix/feat: add loading validation, fix tests * test: fix tests * refactor: no PIN validation in loading schema * test: fix copy-paste error * refactor: use schemas for empty string validation * feat: use salt * refactor/test: reference adaptations * feat: adapt automatic version setting * fix: version in reference * feat: remove salt from dto * test: refactor tests * feat: add/adapt salt validation * refactor/test: validations * test: fix ids * chore: bump backbone * feat: remove version * test: fix salt test * chore: transport PR comments * chore: runtime PR comments * fix/refactor: more stuff * test: correct check * test: fix used function * feat: add transport setting validation * refactor: import * chore: build schemas * refactor: passwordinfo * fix: cleanup * test: cleanup * refactor/fix: use password info derivatives * refactor: remove unused error * test: fix error names in tests * feat: password error message * refactor: test names and content, class usage * feat: runtime interface with flag * test: adapt tests * chore: schemaas * fix: mapping, tests * refactor: simplify object access * refactor: rename passwordProtection * refactor: naming * chore: move business logic to object * refactor: use min * fix: tests * feat: passwordIsPin true or undefined * chore: build schemas * chore: remove unused method * test: fix tests * fix: ability to truncate * refactor: add fromTruncted * feat: adapt tokens to templates * feat: error message mentions wrong password * fix/feat: add missing validations, type cleanup * test: adapt token controller tests * test: adapt runtime tests * chore: schemas * fix: tests, loading token * fix: tests, inheritance * refactor: move expiresAt to schema validator * refactor: move passwordProtection into schema validator * fix: use lodash * refactor: line breaks, comments, lodash * fix: validator * test: protect token * test: remove redundant tests * test: add reference test * chore: build schemas * test: fix error messages * test: fix error code * test: fix error messages * chore: bump backbone * fix: missing password * refactor: namings, restructurings * refactor: generic input validator with password only * refactor: separate test files * test: test names, some fixes * refactor: tokenAndTemplateCreationValidator * refactor: improve tokenAndTemplateCreationValidator * chore: build schemas * refactor: invalidPropertyValue * test: adapt tests --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Julian König <[email protected]> Co-authored-by: Julian König <[email protected]>
- Loading branch information
1 parent
61a8882
commit 2241e42
Showing
35 changed files
with
1,219 additions
and
290 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
BACKBONE_VERSION=6.19.1 | ||
BACKBONE_VERSION=6.20.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
packages/runtime/src/useCases/common/validation/TokenAndTemplateCreationValidator.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { CoreDate } from "@nmshd/core-types"; | ||
import { RuntimeErrors } from "../RuntimeErrors"; | ||
import { JsonSchema } from "../SchemaRepository"; | ||
import { SchemaValidator } from "./SchemaValidator"; | ||
import { ISO8601DateTimeString } from "./ValidatableStrings"; | ||
import { ValidationFailure } from "./ValidationFailure"; | ||
import { ValidationResult } from "./ValidationResult"; | ||
|
||
export class TokenAndTemplateCreationValidator< | ||
T extends { | ||
expiresAt?: ISO8601DateTimeString; | ||
passwordProtection?: { | ||
password: string; | ||
passwordIsPin?: true; | ||
}; | ||
} | ||
> extends SchemaValidator<T> { | ||
public constructor(protected override readonly schema: JsonSchema) { | ||
super(schema); | ||
} | ||
|
||
public override validate(input: T): ValidationResult { | ||
const validationResult = super.validate(input); | ||
|
||
if (input.expiresAt && CoreDate.from(input.expiresAt).isExpired()) { | ||
validationResult.addFailure(new ValidationFailure(RuntimeErrors.general.invalidPropertyValue(`'expiresAt' must be in the future`), "expiresAt")); | ||
} | ||
|
||
if (input.passwordProtection) { | ||
const passwordProtection = input.passwordProtection; | ||
|
||
if (passwordProtection.passwordIsPin) { | ||
if (!/^[0-9]{4,16}$/.test(passwordProtection.password)) { | ||
validationResult.addFailure( | ||
new ValidationFailure( | ||
RuntimeErrors.general.invalidPropertyValue( | ||
`'passwordProtection.passwordIsPin' is true, hence 'passwordProtection.password' must consist of 4 to 16 digits from 0 to 9.` | ||
), | ||
"passwordProtection" | ||
) | ||
); | ||
} | ||
} | ||
} | ||
|
||
return validationResult; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.