This repository was archived by the owner on Mar 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 403
Improve SSO Config validation #1332
Merged
Merged
Changes from all commits
Commits
Show all changes
104 commits
Select commit
Hold shift + click to select a range
a094aff
Refactor to use separate formGroups
eliykat 187c990
Dynamically disable form controls
eliykat d65f9cc
Add required validators
eliykat aa5af2f
Use ngValue to preserve type of all form values
eliykat 9ccb8d0
Add requiredIf validator and form configuration
eliykat e20b696
Move select options to component, form layout
eliykat 811cb57
Simplify requiredIf validator
eliykat b738acf
Add error count message
eliykat 9378bf0
Update strings
eliykat 43f3af1
Minor changes to form config
eliykat 270885d
Add inline error messages, clear errors directive
eliykat 634b171
Add styling for invalid fields
eliykat 427e36b
Update directive name
eliykat bbf341e
Linting
eliykat edfbd2a
Update form labels and layout
eliykat 180b0b3
Move openId customization into own section
eliykat 820b003
Split Sso config form into multiple components
eliykat e97330a
Refactor how parent handles SsoUrls
eliykat 58dfb0f
Update naming conventions
eliykat 4cadf78
Use new patterns for keyConnectorUrl test
eliykat f684d62
Strip spaces from inputs
eliykat ab91710
Move validators to jslib
eliykat 8747abf
Don't validate X509 format
eliykat adddeb8
Add a11y-invalid directive
eliykat 61ce684
Add helper text for openId Authority
eliykat 88d41ee
Add aria-describedby, simplify error messages
eliykat f064bfc
Fix styling on headers
eliykat a8620f2
Add aria-describedby
eliykat ddd1872
Fix styling on section headers
eliykat dacb2ea
Fix linting
eliykat 5b4f3d3
Update copy
eliykat 6828fd4
Fix typo
eliykat fb8412d
Remove unneeded sr-only, fix inline error styling
eliykat f8c6d50
Add default form values
eliykat cc5f891
Simplify templating logic
eliykat ff35922
Use validate on dirty and blur pattern
eliykat dae48a8
Update imports and naming
eliykat 56fb612
Always require X509 Certificate
eliykat eae3201
Remove required validator for keyConnectorUrl
eliykat 1df0ad5
Unblock api call
eliykat 4956558
Fix duplicate keyConnector inline messages
eliykat cf69f64
Add None to SsoType enum
eliykat 2b98662
Use ssoConfigView, restructure forms
eliykat 8fe036e
Use prebuilt dirty validators
eliykat 12c1a23
Add sr-only error text and role=alert for errors
eliykat cc48126
Add field name to inline errors, fix manual validation
eliykat 7e185b8
Refer to fields instead of errors
eliykat 3afbf82
Fix updateOn options
eliykat dc62521
Fix linting and layout
eliykat 88f3ce5
Force screenreader to read out error summary
eliykat d4bccd0
Revert jslib update
eliykat 1a082ab
Revert jslib update
eliykat ec89297
Put everything back into parent component
eliykat 65e7203
Rename fb to formBuilder
eliykat 8c548a9
Merge commit '2b0a9d995e0147601ca8ae4778434a19354a60c2' into fix/sso-…
eliykat b202e07
Run prettier
eliykat 13e44f9
Merge commit '56477eb39cfd8a73c9920577d24d75fed36e2cf5' into fix/sso-…
eliykat 83f0612
Fix merge errors
eliykat 343d968
Revert unrelated formatting change
eliykat 4fca7a5
Revert unrelated formatting changes
eliykat 059271e
Revert accidental jslib update
eliykat 367be41
Fix merge errors
eliykat 2c98a4d
Merge branch 'master' into fix/sso-validation
eliykat 16adf9f
Update jslib for testing purposes
eliykat 37c78c4
Revert "Update jslib for testing purposes"
eliykat cb998a8
Merge branch 'master' into fix/sso-validation
eliykat d2cf1ac
Reapply new icons
eliykat 2206ee0
Reapply update help site URLs
eliykat ae24f31
Refactor: move read only fields to component
eliykat 1fa1143
Fix name
eliykat d0adfa3
Refactor: add input-text component
eliykat db6c8a1
Fix linting
eliykat 58d7c89
Use CVA for input-text component
eliykat 6a3c946
Automatically detect requiredValidator, more flexible error messages
eliykat ef8dcb8
Refactor: use select component
eliykat bd2c6e2
Refactor: use app-input-checkbox component
eliykat 81a5e70
Add whitespace
eliykat fb9639a
Change folder structure
eliykat c59c714
WIP: use CVA base class
eliykat 136dc6f
Use clambda properties instead of methods
eliykat 6e99334
Hook up blur, fix onChanges
eliykat 956816d
Remove unused methods and tidy up
eliykat 8c7f763
Fix linting
eliykat 38cef19
Rename interface
eliykat 0db47d2
Don't load form if no config data received
eliykat a807006
Update name of selector
eliykat 9817d36
Add i18n string
eliykat 9c18392
Move SSO Config Form components into bitwarden_license
eliykat d0288e3
Update jslib
eliykat 4be9625
Add i18n error message
eliykat a40cc0a
Update imports
eliykat 104d339
Merge branch 'master' into fix/sso-validation
eliykat 6edbdfd
Merge branch 'update-jslib' into fix/sso-validation
eliykat 6820a72
Fix aria-invalid and invalid styling
eliykat 1d37ba0
Update jslib
eliykat 31fad71
Merge branch 'master' into fix/sso-validation
eliykat 66b80f7
Remove old string
eliykat c07b565
Add comments
eliykat e27aa99
Fix styling
eliykat 4c7bdf9
Update jslib
eliykat 6a65356
Linting and unused imports
eliykat 54a9c1f
Reset jslib
eliykat a8b0f37
Merge branch 'master' into fix/sso-validation
eliykat 2edc243
Update jslib
eliykat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
bitwarden_license/src/app/organizations/components/base-cva.component.ts
This file contains hidden or 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,68 @@ | ||
| import { Directive, Input, OnInit, Self } from "@angular/core"; | ||
| import { ControlValueAccessor, FormControl, NgControl, Validators } from "@angular/forms"; | ||
|
|
||
| import { dirtyRequired } from "jslib-angular/validators/dirty.validator"; | ||
|
|
||
| /** For use in the SSO Config Form only - will be deprecated by the Component Library */ | ||
| @Directive() | ||
| export abstract class BaseCvaComponent implements ControlValueAccessor, OnInit { | ||
| get describedById() { | ||
| return this.showDescribedBy ? this.controlId + "Desc" : null; | ||
| } | ||
|
|
||
| get showDescribedBy() { | ||
| return this.helperText != null || this.controlDir.control.hasError("required"); | ||
| } | ||
|
|
||
| get isRequired() { | ||
| return ( | ||
| this.controlDir.control.hasValidator(Validators.required) || | ||
| this.controlDir.control.hasValidator(dirtyRequired) | ||
| ); | ||
| } | ||
|
|
||
| @Input() label: string; | ||
| @Input() controlId: string; | ||
| @Input() helperText: string; | ||
|
|
||
| internalControl = new FormControl(""); | ||
|
|
||
| protected onChange: any; | ||
| protected onTouched: any; | ||
|
|
||
| constructor(@Self() public controlDir: NgControl) { | ||
| this.controlDir.valueAccessor = this; | ||
| } | ||
|
|
||
| ngOnInit() { | ||
| this.internalControl.valueChanges.subscribe(this.onValueChangesInternal); | ||
| } | ||
|
|
||
| onBlurInternal() { | ||
| this.onTouched(); | ||
| } | ||
|
|
||
| // CVA interfaces | ||
| writeValue(value: string) { | ||
| this.internalControl.setValue(value); | ||
| } | ||
|
|
||
| registerOnChange(fn: any) { | ||
| this.onChange = fn; | ||
| } | ||
|
|
||
| registerOnTouched(fn: any) { | ||
| this.onTouched = fn; | ||
| } | ||
|
|
||
| setDisabledState(isDisabled: boolean) { | ||
| if (isDisabled) { | ||
| this.internalControl.disable(); | ||
| } else { | ||
| this.internalControl.enable(); | ||
| } | ||
| } | ||
|
|
||
| protected onValueChangesInternal: any = (value: string) => this.onChange(value); | ||
| // End CVA interfaces | ||
| } |
16 changes: 16 additions & 0 deletions
16
bitwarden_license/src/app/organizations/components/input-checkbox.component.html
This file contains hidden or 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,16 @@ | ||
| <div class="form-group"> | ||
| <div class="form-check"> | ||
| <input | ||
| class="form-check-input" | ||
| type="checkbox" | ||
| [attr.id]="controlId" | ||
| [attr.aria-describedby]="describedById" | ||
| [formControl]="internalControl" | ||
| (blur)="onBlurInternal()" | ||
| /> | ||
| <label class="form-check-label" [attr.for]="controlId">{{ label }}</label> | ||
| </div> | ||
| <small *ngIf="showDescribedBy" [attr.id]="describedById" class="form-text text-muted">{{ | ||
| helperText | ||
| }}</small> | ||
| </div> |
10 changes: 10 additions & 0 deletions
10
bitwarden_license/src/app/organizations/components/input-checkbox.component.ts
This file contains hidden or 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,10 @@ | ||
| import { Component } from "@angular/core"; | ||
|
|
||
| import { BaseCvaComponent } from "./base-cva.component"; | ||
|
|
||
| /** For use in the SSO Config Form only - will be deprecated by the Component Library */ | ||
| @Component({ | ||
| selector: "app-input-checkbox", | ||
| templateUrl: "input-checkbox.component.html", | ||
| }) | ||
| export class InputCheckboxComponent extends BaseCvaComponent {} |
26 changes: 26 additions & 0 deletions
26
bitwarden_license/src/app/organizations/components/input-text-readonly.component.html
This file contains hidden or 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,26 @@ | ||
| <div class="form-group"> | ||
| <label>{{ label }}</label> | ||
| <div class="input-group"> | ||
| <input class="form-control" readonly [value]="controlValue" /> | ||
| <div class="input-group-append" *ngIf="showLaunch"> | ||
| <button | ||
| type="button" | ||
| class="btn btn-outline-secondary" | ||
| appA11yTitle="{{ 'launch' | i18n }}" | ||
| (click)="launchUri(controlValue)" | ||
| > | ||
| <i class="bwi bwi-lg bwi-external-link" aria-hidden="true"></i> | ||
| </button> | ||
| </div> | ||
| <div class="input-group-append" *ngIf="showCopy"> | ||
| <button | ||
| type="button" | ||
| class="btn btn-outline-secondary" | ||
| appA11yTitle="{{ 'copyValue' | i18n }}" | ||
| (click)="copy(controlValue)" | ||
| > | ||
| <i class="bwi bwi-lg bwi-clone" aria-hidden="true"></i> | ||
| </button> | ||
| </div> | ||
| </div> | ||
| </div> |
25 changes: 25 additions & 0 deletions
25
bitwarden_license/src/app/organizations/components/input-text-readonly.component.ts
This file contains hidden or 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,25 @@ | ||
| import { Component, Input } from "@angular/core"; | ||
|
|
||
| import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service"; | ||
|
|
||
| /** For use in the SSO Config Form only - will be deprecated by the Component Library */ | ||
| @Component({ | ||
| selector: "app-input-text-readonly", | ||
| templateUrl: "input-text-readonly.component.html", | ||
| }) | ||
| export class InputTextReadOnlyComponent { | ||
| @Input() controlValue: string; | ||
| @Input() label: string; | ||
| @Input() showCopy = true; | ||
| @Input() showLaunch = false; | ||
|
|
||
| constructor(private platformUtilsService: PlatformUtilsService) {} | ||
|
|
||
| copy(value: string) { | ||
| this.platformUtilsService.copyToClipboard(value); | ||
| } | ||
|
|
||
| launchUri(url: string) { | ||
| this.platformUtilsService.launchUri(url); | ||
| } | ||
| } |
33 changes: 33 additions & 0 deletions
33
bitwarden_license/src/app/organizations/components/input-text.component.html
This file contains hidden or 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,33 @@ | ||
| <div class="form-group"> | ||
| <label [attr.for]="controlId"> | ||
| {{ label }} | ||
| <small *ngIf="isRequired" class="text-muted form-text d-inline" | ||
| >({{ "required" | i18n }})</small | ||
| > | ||
| </label> | ||
| <input | ||
| [formControl]="internalControl" | ||
| class="form-control" | ||
| [attr.id]="controlId" | ||
| [attr.aria-describedby]="describedById" | ||
| [attr.aria-invalid]="controlDir.control.invalid" | ||
| (blur)="onBlurInternal()" | ||
| /> | ||
| <div *ngIf="showDescribedBy" [attr.id]="describedById"> | ||
| <small | ||
| *ngIf="helperText != null && !controlDir.control.hasError(helperTextSameAsError)" | ||
| class="form-text text-muted" | ||
| > | ||
| {{ helperText }} | ||
| </small> | ||
| <small class="error-inline" *ngIf="controlDir.control.hasError('required')" role="alert"> | ||
| <i class="bwi bwi-exclamation-circle" aria-hidden="true"></i> | ||
| <span class="sr-only">{{ "error" | i18n }}:</span> | ||
| {{ | ||
| controlDir.control.hasError(helperTextSameAsError) | ||
| ? helperText | ||
| : ("fieldRequiredError" | i18n: label) | ||
| }} | ||
| </small> | ||
| </div> | ||
| </div> |
48 changes: 48 additions & 0 deletions
48
bitwarden_license/src/app/organizations/components/input-text.component.ts
This file contains hidden or 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 { Component, Input, OnInit } from "@angular/core"; | ||
|
|
||
| import { BaseCvaComponent } from "./base-cva.component"; | ||
|
|
||
| /** For use in the SSO Config Form only - will be deprecated by the Component Library */ | ||
| @Component({ | ||
| selector: "app-input-text[label][controlId]", | ||
| templateUrl: "input-text.component.html", | ||
| }) | ||
| export class InputTextComponent extends BaseCvaComponent implements OnInit { | ||
| @Input() helperTextSameAsError: string; | ||
| @Input() requiredErrorMessage: string; | ||
| @Input() stripSpaces = false; | ||
|
|
||
| transformValue: (value: string) => string = null; | ||
|
|
||
| ngOnInit() { | ||
| super.ngOnInit(); | ||
| if (this.stripSpaces) { | ||
| this.transformValue = this.doStripSpaces; | ||
| } | ||
| } | ||
|
|
||
| writeValue(value: string) { | ||
| this.internalControl.setValue(value == null ? "" : value); | ||
| } | ||
|
|
||
| protected onValueChangesInternal: any = (value: string) => { | ||
| let newValue = value; | ||
| if (this.transformValue != null) { | ||
| newValue = this.transformValue(value); | ||
| this.internalControl.setValue(newValue, { emitEvent: false }); | ||
| } | ||
| this.onChange(newValue); | ||
| }; | ||
|
|
||
| protected onValueChangeInternal(value: string) { | ||
| let newValue = value; | ||
| if (this.transformValue != null) { | ||
| newValue = this.transformValue(value); | ||
| this.internalControl.setValue(newValue, { emitEvent: false }); | ||
| } | ||
| } | ||
|
|
||
| private doStripSpaces(value: string) { | ||
| return value.replace(/ /g, ""); | ||
| } | ||
| } | ||
19 changes: 19 additions & 0 deletions
19
bitwarden_license/src/app/organizations/components/select.component.html
This file contains hidden or 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,19 @@ | ||
| <div class="form-group"> | ||
| <label [attr.for]="controlId"> | ||
| {{ label }} | ||
| <small *ngIf="isRequired" class="text-muted form-text d-inline" | ||
| >({{ "required" | i18n }})</small | ||
| > | ||
| </label> | ||
| <select | ||
| class="form-control" | ||
| [attr.id]="controlId" | ||
| [attr.aria-invalid]="controlDir.control.invalid" | ||
| [formControl]="internalControl" | ||
| (blur)="onBlurInternal()" | ||
| > | ||
| <option *ngFor="let o of selectOptions" [ngValue]="o.value" disabled="{{ o.disabled }}"> | ||
| {{ o.name }} | ||
| </option> | ||
| </select> | ||
| </div> |
14 changes: 14 additions & 0 deletions
14
bitwarden_license/src/app/organizations/components/select.component.ts
This file contains hidden or 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,14 @@ | ||
| import { Component, Input } from "@angular/core"; | ||
|
|
||
| import { SelectOptions } from "jslib-angular/interfaces/selectOptions"; | ||
|
|
||
| import { BaseCvaComponent } from "./base-cva.component"; | ||
|
|
||
| /** For use in the SSO Config Form only - will be deprecated by the Component Library */ | ||
| @Component({ | ||
| selector: "app-select", | ||
| templateUrl: "select.component.html", | ||
| }) | ||
| export class SelectComponent extends BaseCvaComponent { | ||
| @Input() selectOptions: SelectOptions[]; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.