Skip to content

KEYCLOAK-2045 Simple Validation SPI for UserProfile SPI - #8053

Merged
pedroigor merged 2 commits into
keycloak:masterfrom
velias:KEYCLOAK-2045-Simple-Validation-SPI
May 19, 2021
Merged

pedroigor merged 2 commits into
keycloak:masterfrom
velias:KEYCLOAK-2045-Simple-Validation-SPI

Conversation

@velias

@velias velias commented May 18, 2021 •

Copy link
Copy Markdown
Contributor

KEYCLOAK-2045 Simple Validation SPI - this PR is follow up of the original PR #7887 by @thomasdarimont. It is refined to work for UserProfile SPI. Main changes against the original PR:

  • default "format" validators like email, length, pattern etc improved to work on List of Strings (as UserProfile attributes are List of Strings). Added reusable abstract base classes to make implementation for this kind of validators easier.
  • improved handling of null values in default validators (treated as valid values now) to allow format validations for optional attributes in UserProfile.
  • improved validation of configuration for some default validators
  • added validator for integer and double numbers which also allows to validate configured min and max values
  • changed package for default validators (agreed with @pedroigor )
  • added error messages for errors produced by default validators into /base/login theme resources
  • removed unnecessary changes to keycloak basic classes (like KeycloakSession)

KEYCLOAK-2045 Return ValidationContext with the outcome of the validation in validate methods

KEYCLOAK-2045 Move validator lookup from KeycloakSession into dedicated ValidatorLookup class for now

KEYCLOAK-2045 Validator SPI polishing

KEYCLOAK-2045 Move Validator SPI to server-spi-private for now

KEYCLOAK-2045 Add test to demonstrate validator config validation.

KEYCLOAK-2045 Add support for context-less validations.

KEYCLOAK-2045 Introduce ValidatorConfig and add some default Validator implementations

KEYCLOAK-2045 Add license headers

KEYCLOAK-2045 Revise BuiltinValidators

KEYCLOAK-2045 Validator Polishing

KEYCLOAK-2045 Allow lookups for ValidatorFactories for dynamic config validation.

KEYCLOAK-2045 Revise ValidatorTests

KEYCLOAK-2045 Validator Polishing

KEYCLOAK-2045 Add example for nested validation

KEYCLOAK-2045 Refactor Validator API

KEYCLOAK-2045 Refactor Validator API

- Merged BuiltinValidators and ValidatorLookup into Validators facade class

KEYCLOAK-2045 Ease validation of ValidatorConfigs

KEYCLOAK-2045 Assume ValidatorConfig's are valid for Validator's that don't support config.

KEYCLOAK-2045 Make built-in validator method names more for static imports

KEYCLOAK-2045 Revise Validation API according to discussions from code review

KEYCLOAK-2045 Pass KeycloakSession to ValidatorConfig validation methods.

This allows ValidatorConfig validations to access services as well as
the current KeycloakContext.

KEYCLOAK-2045 Revise Validation API according to discussions from code review

- Derive valid state from errors in ValidationContext
- Simplify ValidationResult by not inheriting from Consumer<Consmer<ValidationResult>>
- Add addtional test cases

KEYCLOAK-2045 Revise Validation API according to discussions from code review

- Revise NumberValidator to only check for double conversion
- Removed support for string based regex pattern

KEYCLOAK-2045 Ease validation of ValidatorConfig
@pedroigor

Copy link
Copy Markdown
Contributor

@pedroigor pedroigor added area/core Core server — startup, configuration, providers/SPIs, cross-cutting concerns kind/enhancement Categorizes a PR related to an enhancement status/in-review labels May 18, 2021
@velias

velias commented May 19, 2021

Copy link
Copy Markdown
Contributor Author

@pedroigor thanks, added few comments to your additional commit. My biggest concern is around format validations over empty strings and how it will work for optional fields in UserProfile (I think registration/update forms produce empty string for them now if not changed in meantime). Do we have final UserProfile functionality merged with this latest version of validators somewhere to test it?

@velias
velias force-pushed the KEYCLOAK-2045-Simple-Validation-SPI branch from fdcf698 to de47dcb Compare May 19, 2021 12:17
@velias

velias commented May 19, 2021

Copy link
Copy Markdown
Contributor Author

@pedroigor incorporated your changes with some additional changes from me mainly to patch number range validation
I kept your change when empty strings are treated as invalid by String format validators (Email, Pattern, length). We have to make sure UserProfile SPI parts where registration and profile update form data are processed work correctly for optional attributes.

@velias
velias force-pushed the KEYCLOAK-2045-Simple-Validation-SPI branch from de47dcb to 59c3b21 Compare May 19, 2021 13:04
@pedroigor

Copy link
Copy Markdown
Contributor

@thomasdarimont @velias Thanks.

@pedroigor
pedroigor merged commit 0913a22 into keycloak:master May 19, 2021
SergiusAC pushed a commit to SergiusAC/keycloak that referenced this pull request May 20, 2021
* KEYCLOAK-2045 Simple Validation API

Co-authored-by: Thomas Darimont <thomas.darimont@googlemail.com>
@velias
velias deleted the KEYCLOAK-2045-Simple-Validation-SPI branch May 20, 2021 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Core server — startup, configuration, providers/SPIs, cross-cutting concerns kind/enhancement Categorizes a PR related to an enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants