Skip to content

Commit 0a1f89b

Browse files
lsongsusexingzhang-suse
authored andcommitted
[Feat] Mask sensitive values displayed in the NeuVector UI under the SAML configuration, such as certificates, group names, and tenant ID
1 parent 4b694f4 commit 0a1f89b

5 files changed

Lines changed: 77 additions & 5 deletions

File tree

admin/webapp/websrc/app/routes/settings/common/group-domain-role/group-domain-role.component.html

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,25 @@
3232
</ng-container>
3333
<ng-container matColumnDef="group">
3434
<mat-header-cell *matHeaderCellDef class="group">{{
35-
'ldap.gridHeader.GROUP' | translate
36-
}}</mat-header-cell>
37-
<mat-cell *matCellDef="let element" class="group">
38-
{{ element.group }}
35+
'ldap.gridHeader.GROUP' | translate
36+
}}</mat-header-cell>
37+
<mat-cell *matCellDef="let element" class="group d-flex align-items-center">
38+
<span [class.password-masked]="!element.isGroupVisible">
39+
{{ element.group }}
40+
</span>
41+
42+
<button
43+
*ngIf="element.group"
44+
(click)="element.isGroupVisible = !element.isGroupVisible"
45+
aria-label="Visibility icon to toggle visibility"
46+
mat-icon-button
47+
class="ms-2"
48+
style="width: 24px; height: 24px; line-height: 24px; padding: 0;"
49+
type="button">
50+
<i class="eos-icons" style="font-size: 16px;">
51+
{{ element.isGroupVisible ? 'visibility' : 'visibility_off' }}
52+
</i>
53+
</button>
3954
</mat-cell>
4055
</ng-container>
4156
<ng-container matColumnDef="globalRole">

admin/webapp/websrc/app/routes/settings/common/group-domain-role/group-domain-role.component.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,7 @@ i {
6767
pointer-events: auto;
6868
cursor: grabbing;
6969
}
70+
71+
.password-masked {
72+
-webkit-text-security: disc;
73+
}

admin/webapp/websrc/app/routes/settings/saml/saml-form/saml-form.component.html

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,27 @@
7474
<mat-label>{{ 'okta.SLO_CERT' | translate }}</mat-label>
7575
<textarea
7676
cdkTextareaAutosize
77+
[class.password-masked]="!sloCertVisible"
7778
formControlName="signing_cert"
7879
matInput></textarea>
7980
</mat-form-field>
81+
<button
82+
(click)="sloCertVisible = !sloCertVisible"
83+
*ngIf="samlForm.controls.signing_cert.value"
84+
aria-label="Visibility icon to toggle visibility"
85+
class="mb-4"
86+
mat-icon-button
87+
type="button">
88+
<i class="eos-icons">{{ sloCertVisible ? 'visibility' : 'visibility_off' }}</i>
89+
</button>
8090
</div>
8191
<div class="col-12 col-md-6 d-flex align-items-center my-2 my-md-0">
8292
<i class="eos-icons me-3 text-primary mb-4">vpn_key</i>
8393
<mat-form-field class="w-100">
8494
<mat-label>{{ 'okta.SLO_KEY' | translate }}</mat-label>
8595
<textarea
8696
cdkTextareaAutosize
97+
[class.password-masked]="!sloKeyVisible"
8798
formControlName="signing_key"
8899
matInput></textarea>
89100
<mat-icon
@@ -94,6 +105,15 @@
94105
info
95106
</mat-icon>
96107
</mat-form-field>
108+
<button
109+
(click)="sloKeyVisible = !sloKeyVisible"
110+
*ngIf="samlForm.controls.signing_key.value"
111+
aria-label="Visibility icon to toggle visibility"
112+
class="mb-4"
113+
mat-icon-button
114+
type="button">
115+
<i class="eos-icons">{{ sloKeyVisible ? 'visibility' : 'visibility_off' }}</i>
116+
</button>
97117
</div>
98118
<ng-container formArrayName="x509_certs">
99119
<div
@@ -105,22 +125,43 @@
105125
<mat-label>{{ 'okta.CERTIFICATE' | translate }}</mat-label>
106126
<textarea
107127
cdkTextareaAutosize
128+
[class.password-masked]="!x509CertVisible[i]"
108129
[formControlName]="i"
109130
matInput></textarea>
110131
<mat-error *ngIf="x509_certs.controls[0].hasError('required')">
111132
{{ 'general.REQUIRED' | translate }}
112133
</mat-error>
113134
</mat-form-field>
135+
<button
136+
(click)="x509CertVisible[i] = !x509CertVisible[i]"
137+
*ngIf="x509_certs.controls[i].value"
138+
aria-label="Visibility icon to toggle visibility"
139+
class="mb-4"
140+
mat-icon-button
141+
type="button">
142+
<i class="eos-icons">{{ x509CertVisible[i] ? 'visibility' : 'visibility_off' }}</i>
143+
</button>
114144
</ng-container>
145+
115146
<ng-template #extraCertTemplate>
116147
<i class="eos-icons me-3 text-primary invisible mb-4">verified</i>
117148
<mat-form-field class="w-100">
118149
<mat-label>{{ 'okta.EXTRA_CERT' | translate }}</mat-label>
119150
<textarea
120151
cdkTextareaAutosize
152+
[class.password-masked]="!x509CertVisible[i]"
121153
[formControlName]="i"
122154
matInput></textarea>
123155
</mat-form-field>
156+
<button
157+
(click)="x509CertVisible[i] = !x509CertVisible[i]"
158+
*ngIf="x509_certs.controls[i].value"
159+
aria-label="Visibility icon to toggle visibility"
160+
class="mb-4"
161+
mat-icon-button
162+
type="button">
163+
<i class="eos-icons">{{ x509CertVisible[i] ? 'visibility' : 'visibility_off' }}</i>
164+
</button>
124165
<button
125166
(click)="removeExtraCert(i)"
126167
aria-label="Remove extra X509_cert"
@@ -132,6 +173,7 @@
132173
</ng-template>
133174
</div>
134175
</ng-container>
176+
135177
<div
136178
class="col-12 d-flex align-items-center"
137179
*ngIf="x509_certs.length <= 3">

admin/webapp/websrc/app/routes/settings/saml/saml-form/saml-form.component.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@
88
.icon-16 {
99
font-size: 16px;
1010
}
11+
12+
.password-masked {
13+
-webkit-text-security: disc;
14+
}

admin/webapp/websrc/app/routes/settings/saml/saml-form/saml-form.component.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import { NotificationService } from '@services/notification.service';
2323
import { TranslateService } from '@ngx-translate/core';
2424
import { Observable } from 'rxjs';
2525
import { AuthUtilsService } from '@common/utils/auth.utils';
26-
import { MatSlideToggleChange } from '@angular/material/slide-toggle';
2726

2827
@Component({
2928
standalone: false,
@@ -40,6 +39,9 @@ export class SamlFormComponent implements OnInit, OnChanges {
4039
groupMappedRoles: GroupMappedRole[] = [];
4140
serverName = 'saml1';
4241
passwordVisible = false;
42+
sloCertVisible = false;
43+
sloKeyVisible = false;
44+
x509CertVisible: boolean[] = [];
4345
samlRedirectURL!: string;
4446
samlForm = new FormGroup({
4547
sso_url: new FormControl(null, [Validators.required, urlValidator()]),
@@ -102,13 +104,15 @@ export class SamlFormComponent implements OnInit, OnChanges {
102104

103105
initForm(): void {
104106
this.x509_certs.clear();
107+
this.x509CertVisible = [];
105108
const saml = this.samlData.server.servers.find(
106109
({ server_type }) => server_type === 'saml'
107110
);
108111
if (saml && saml.saml) {
109112
this.serverName = saml.server_name;
110113
this.groupMappedRoles = saml.saml.group_mapped_roles || [];
111114
saml.saml.x509_certs.forEach((x509_cert, idx) => {
115+
this.x509CertVisible.push(false);
112116
this.x509_certs.push(
113117
new FormControl(
114118
x509_cert.x509_cert,
@@ -130,6 +134,7 @@ export class SamlFormComponent implements OnInit, OnChanges {
130134
this.isCreated = false;
131135
}
132136
if (!this.x509_certs.length) {
137+
this.x509CertVisible.push(false);
133138
this.x509_certs.push(new FormControl('', [Validators.required]));
134139
}
135140
}
@@ -185,10 +190,12 @@ export class SamlFormComponent implements OnInit, OnChanges {
185190
}
186191

187192
addExtraCert() {
193+
this.x509CertVisible.push(false);
188194
this.x509_certs.push(new FormControl(''));
189195
}
190196

191197
removeExtraCert(index: number) {
198+
this.x509CertVisible.splice(index, 1);
192199
this.x509_certs.removeAt(index);
193200
}
194201
}

0 commit comments

Comments
 (0)