Skip to content

Commit 5d0e16d

Browse files
author
Aashish Sharma
committed
mgr/dashboard: remove the option for authentication with token in
multi-cluster form Signed-off-by: Aashish Sharma <[email protected]>
1 parent 1fd2d36 commit 5d0e16d

File tree

6 files changed

+49
-134
lines changed

6 files changed

+49
-134
lines changed

src/pybind/mgr/dashboard/controllers/multi_cluster.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ def _proxy(self, method, base_url, path, params=None, payload=None, verify=False
5454
@CreatePermission
5555
@EndpointDoc("Authenticate to a remote cluster")
5656
def auth(self, url: str, cluster_alias: str, username: str,
57-
password=None, token=None, hub_url=None, cluster_fsid=None,
58-
prometheus_api_url=None, ssl_verify=False, ssl_certificate=None, ttl=None):
59-
57+
password=None, hub_url=None, ssl_verify=False, ssl_certificate=None, ttl=None):
6058
try:
6159
hub_fsid = mgr.get('config')['fsid']
6260
except KeyError:
@@ -101,12 +99,7 @@ def auth(self, url: str, cluster_alias: str, username: str,
10199
ssl_verify, ssl_certificate)
102100
return True
103101

104-
if token and cluster_fsid and prometheus_api_url:
105-
_set_prometheus_targets(prometheus_api_url)
106-
self.set_multi_cluster_config(cluster_fsid, username, url,
107-
cluster_alias, token, prometheus_api_url,
108-
ssl_verify, ssl_certificate)
109-
return True
102+
return False
110103

111104
def check_cluster_connection(self, url, payload, username, ssl_verify, ssl_certificate):
112105
try:
@@ -200,7 +193,7 @@ def set_config(self, config: object):
200193
@Endpoint('PUT')
201194
@UpdatePermission
202195
# pylint: disable=W0613
203-
def reconnect_cluster(self, url: str, username=None, password=None, token=None,
196+
def reconnect_cluster(self, url: str, username=None, password=None,
204197
ssl_verify=False, ssl_certificate=None, ttl=None):
205198
multicluster_config = self.load_multi_cluster_config()
206199
if username and password:

src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/multi-cluster/multi-cluster-form/multi-cluster-form.component.html

Lines changed: 25 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,6 @@
1717
spacingClass="mb-3"
1818
i18n>{{ connectionMessage }}
1919
</cd-alert-panel>
20-
<cd-alert-panel type="info"
21-
spacingClass="mb-3"
22-
i18n
23-
*ngIf="connectionVerified !== undefined && !connectionVerified && connectionMessage === 'Connection refused' || remoteClusterForm.getValue('showToken')">
24-
<p>You need to set this cluster's url as the cross origin url in the remote cluster you are trying to connect.
25-
You can do it by running this CLI command in your remote cluster and proceed with authentication via token.</p>
26-
<cd-code-block [codes]="[crossOriginCmd]"></cd-code-block>
27-
</cd-alert-panel>
2820
<div class="form-group row">
2921
<label class="cd-col-form-label required"
3022
for="remoteClusterUrl"
@@ -53,6 +45,10 @@
5345
*ngIf="remoteClusterForm.showError('remoteClusterUrl', frm, 'endpoint')"
5446
i18n>Please enter a valid URL.
5547
</span>
48+
<span class="invalid-feedback"
49+
*ngIf="remoteClusterForm.showError('remoteClusterUrl', frm, 'hubUrlCheck')"
50+
i18n>The hub cluster cannot be connected.
51+
</span>
5652
</div>
5753
</div>
5854
<div class="form-group row">
@@ -100,51 +96,7 @@
10096
</div>
10197
</div>
10298
<div class="form-group row"
103-
*ngIf="remoteClusterForm.getValue('showToken') && action !== 'edit'">
104-
<label class="cd-col-form-label required"
105-
for="clusterFsid"
106-
i18n>Cluster FSID
107-
</label>
108-
<div class="cd-col-form-input">
109-
<input id="clusterFsid"
110-
name="clusterFsid"
111-
class="form-control"
112-
type="text"
113-
formControlName="clusterFsid">
114-
<span class="invalid-feedback"
115-
*ngIf="remoteClusterForm.showError('clusterFsid', frm, 'required')"
116-
i18n>This field is required.
117-
</span>
118-
</div>
119-
</div>
120-
<div class="form-group row"
121-
*ngIf="remoteClusterForm.getValue('showToken') && action !== 'edit'">
122-
<label class="cd-col-form-label required"
123-
for="prometheusApiUrl"
124-
i18n>Prometheus API URL
125-
<cd-helper>
126-
<span>
127-
<p>Enter the Prometheus API URL. You can retrieve it from the CLI with: <b>{{ prometheusApiUrlCmd }} </b>
128-
<cd-copy-2-clipboard-button [source]="prometheusApiUrlCmd"
129-
[byId]="false"></cd-copy-2-clipboard-button>
130-
</p>
131-
</span>
132-
</cd-helper>
133-
</label>
134-
<div class="cd-col-form-input">
135-
<input id="prometheusApiUrl"
136-
name="prometheusApiUrl"
137-
class="form-control"
138-
type="text"
139-
formControlName="prometheusApiUrl">
140-
<span class="invalid-feedback"
141-
*ngIf="remoteClusterForm.showError('prometheusApiUrl', frm, 'required')"
142-
i18n>This field is required.
143-
</span>
144-
</div>
145-
</div>
146-
<div class="form-group row"
147-
*ngIf="!remoteClusterForm.getValue('showToken') && !showCrossOriginError && action !== 'edit'">
99+
*ngIf="action !== 'edit'">
148100
<label class="cd-col-form-label required"
149101
for="password"
150102
i18n>Password
@@ -172,24 +124,7 @@
172124
</div>
173125
</div>
174126
<div class="form-group row"
175-
*ngIf="remoteClusterForm.getValue('showToken') && action !== 'edit'">
176-
<label class="cd-col-form-label required"
177-
for="apiToken"
178-
i18n>Token
179-
</label>
180-
<div class="cd-col-form-input">
181-
<input id="apiToken"
182-
name="apiToken"
183-
class="form-control"
184-
type="text"
185-
formControlName="apiToken">
186-
<span class="invalid-feedback"
187-
*ngIf="remoteClusterForm.showError('apiToken', frm, 'required')"
188-
i18n>This field is required.</span>
189-
</div>
190-
</div>
191-
<div class="form-group row"
192-
*ngIf="!remoteClusterForm.getValue('showToken') && action !== 'edit'">
127+
*ngIf="action !== 'edit'">
193128
<label class="cd-col-form-label"
194129
for="ttl"
195130
i18n>Login Expiration</label>
@@ -206,6 +141,24 @@
206141
</select>
207142
</div>
208143
</div>
144+
<!--
145+
<div class="form-group row"
146+
*ngIf="action !== 'edit'">
147+
<label class="cd-col-form-label required"
148+
for="apiToken"
149+
i18n>Token
150+
</label>
151+
<div class="cd-col-form-input">
152+
<input id="apiToken"
153+
name="apiToken"
154+
class="form-control"
155+
type="text"
156+
formControlName="apiToken">
157+
<span class="invalid-feedback"
158+
*ngIf="remoteClusterForm.showError('apiToken', frm, 'required')"
159+
i18n>This field is required.</span>
160+
</div>
161+
</div>
209162
<div class="form-group row"
210163
*ngIf="action !== 'edit'">
211164
<div class="cd-col-form-offset">
@@ -221,7 +174,7 @@
221174
i18n>Auth with token</label>
222175
</div>
223176
</div>
224-
</div>
177+
</div> -->
225178
<!-- ssl -->
226179
<div class="form-group row">
227180
<div class="cd-col-form-offset">

src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/multi-cluster/multi-cluster-form/multi-cluster-form.component.ts

Lines changed: 16 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,30 @@ export class MultiClusterFormComponent implements OnInit, OnDestroy {
2323
readonly ipv4Rgx = /^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/i;
2424
readonly ipv6Rgx = /^(?:[a-f0-9]{1,4}:){7}[a-f0-9]{1,4}$/i;
2525
clusterApiUrlCmd = 'ceph mgr services';
26-
prometheusApiUrlCmd = 'ceph config get mgr mgr/dashboard/PROMETHEUS_API_HOST';
27-
crossOriginCmd = `ceph dashboard set-cross-origin-url ${window.location.origin}`;
2826
remoteClusterForm: CdFormGroup;
29-
showToken = false;
3027
connectionVerified: boolean;
3128
connectionMessage = '';
3229
private subs = new Subscription();
33-
showCrossOriginError = false;
3430
action: string;
3531
cluster: MultiCluster;
3632
clustersData: MultiCluster[];
3733
clusterAliasNames: string[];
3834
clusterUrls: string[];
3935
clusterUsers: string[];
4036
clusterUrlUserMap: Map<string, string>;
37+
hubUrl: string;
4138

4239
constructor(
4340
public activeModal: NgbActiveModal,
4441
public actionLabels: ActionLabelsI18n,
4542
public notificationService: NotificationService,
4643
private multiClusterService: MultiClusterService
4744
) {
45+
this.subs.add(
46+
this.multiClusterService.subscribe((resp: any) => {
47+
this.hubUrl = resp['hub_url'];
48+
})
49+
);
4850
this.createForm();
4951
}
5052
ngOnInit(): void {
@@ -62,8 +64,6 @@ export class MultiClusterFormComponent implements OnInit, OnDestroy {
6264
this.remoteClusterForm.get('clusterAlias').disable();
6365
this.remoteClusterForm.get('username').setValue(this.cluster.user);
6466
this.remoteClusterForm.get('username').disable();
65-
this.remoteClusterForm.get('clusterFsid').setValue(this.cluster.name);
66-
this.remoteClusterForm.get('clusterFsid').disable();
6767
this.remoteClusterForm.get('ssl').setValue(this.cluster.ssl_verify);
6868
this.remoteClusterForm.get('ssl_cert').setValue(this.cluster.ssl_certificate);
6969
}
@@ -76,7 +76,7 @@ export class MultiClusterFormComponent implements OnInit, OnDestroy {
7676

7777
createForm() {
7878
this.remoteClusterForm = new CdFormGroup({
79-
showToken: new FormControl(false),
79+
// showToken: new FormControl(false),
8080
username: new FormControl('', [
8181
CdValidators.custom('uniqueUrlandUser', (username: string) => {
8282
let remoteClusterUrl = '';
@@ -96,16 +96,6 @@ export class MultiClusterFormComponent implements OnInit, OnDestroy {
9696
);
9797
})
9898
]),
99-
clusterFsid: new FormControl('', [
100-
CdValidators.requiredIf({
101-
showToken: true
102-
})
103-
]),
104-
prometheusApiUrl: new FormControl('', [
105-
CdValidators.requiredIf({
106-
showToken: true
107-
})
108-
]),
10999
password: new FormControl('', []),
110100
remoteClusterUrl: new FormControl(null, {
111101
validators: [
@@ -120,14 +110,17 @@ export class MultiClusterFormComponent implements OnInit, OnDestroy {
120110
);
121111
}
122112
}),
113+
CdValidators.custom('hubUrlCheck', (remoteClusterUrl: string) => {
114+
return this.action === 'connect' && remoteClusterUrl?.includes(this.hubUrl);
115+
}),
123116
Validators.required
124117
]
125118
}),
126-
apiToken: new FormControl('', [
127-
CdValidators.requiredIf({
128-
showToken: true
129-
})
130-
]),
119+
// apiToken: new FormControl('', [
120+
// CdValidators.requiredIf({
121+
// showToken: true
122+
// })
123+
// ]),
131124
clusterAlias: new FormControl(null, {
132125
validators: [
133126
Validators.required,
@@ -159,9 +152,7 @@ export class MultiClusterFormComponent implements OnInit, OnDestroy {
159152
handleError(error: any): void {
160153
if (error.error.code === 'connection_refused') {
161154
this.connectionVerified = false;
162-
this.showCrossOriginError = true;
163155
this.connectionMessage = error.error.detail;
164-
this.crossOriginCmd = `ceph config set mgr mgr/dashboard/cross_origin_url ${window.location.origin} `;
165156
} else {
166157
this.connectionVerified = false;
167158
this.connectionMessage = error.error.detail;
@@ -189,9 +180,6 @@ export class MultiClusterFormComponent implements OnInit, OnDestroy {
189180
const clusterAlias = this.remoteClusterForm.getValue('clusterAlias');
190181
const username = this.remoteClusterForm.getValue('username');
191182
const password = this.remoteClusterForm.getValue('password');
192-
const token = this.remoteClusterForm.getValue('apiToken');
193-
const clusterFsid = this.remoteClusterForm.getValue('clusterFsid');
194-
const prometheusApiUrl = this.remoteClusterForm.getValue('prometheusApiUrl');
195183
const ssl = this.remoteClusterForm.getValue('ssl');
196184
const ttl = this.convertToHours(this.remoteClusterForm.getValue('ttl'));
197185
const ssl_certificate = this.remoteClusterForm.getValue('ssl_cert')?.trim();
@@ -219,7 +207,7 @@ export class MultiClusterFormComponent implements OnInit, OnDestroy {
219207
case 'reconnect':
220208
this.subs.add(
221209
this.multiClusterService
222-
.reConnectCluster(updatedUrl, username, password, token, ssl, ssl_certificate, ttl)
210+
.reConnectCluster(updatedUrl, username, password, ssl, ssl_certificate, ttl)
223211
.subscribe(commonSubscribtion)
224212
);
225213
break;
@@ -231,10 +219,7 @@ export class MultiClusterFormComponent implements OnInit, OnDestroy {
231219
clusterAlias,
232220
username,
233221
password,
234-
token,
235222
window.location.origin,
236-
clusterFsid,
237-
prometheusApiUrl,
238223
ssl,
239224
ssl_certificate,
240225
ttl
@@ -247,10 +232,6 @@ export class MultiClusterFormComponent implements OnInit, OnDestroy {
247232
}
248233
}
249234

250-
toggleToken() {
251-
this.showToken = !this.showToken;
252-
}
253-
254235
fileUpload(files: FileList, controlName: string) {
255236
const file: File = files[0];
256237
const reader = new FileReader();

src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/multi-cluster/multi-cluster-list/multi-cluster-list.component.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { MultiCluster } from '~/app/shared/models/multi-cluster';
1919
import { Router } from '@angular/router';
2020
import { CookiesService } from '~/app/shared/services/cookie.service';
2121
import { Observable, Subscription } from 'rxjs';
22+
import { SettingsService } from '~/app/shared/api/settings.service';
2223

2324
@Component({
2425
selector: 'cd-multi-cluster-list',
@@ -55,7 +56,8 @@ export class MultiClusterListComponent implements OnInit, OnDestroy {
5556
private notificationService: NotificationService,
5657
private authStorageService: AuthStorageService,
5758
private modalService: ModalService,
58-
private cookieService: CookiesService
59+
private cookieService: CookiesService,
60+
private settingsService: SettingsService
5961
) {
6062
this.tableActions = [
6163
{
@@ -162,6 +164,8 @@ export class MultiClusterListComponent implements OnInit, OnDestroy {
162164
this.checkClusterConnectionStatus();
163165
})
164166
);
167+
168+
this.managedByConfig$ = this.settingsService.getValues('MANAGED_BY_CLUSTERS');
165169
}
166170

167171
ngOnDestroy(): void {

src/pybind/mgr/dashboard/frontend/src/app/shared/api/multi-cluster.service.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,7 @@ export class MultiClusterService {
128128
clusterAlias: string,
129129
username: string,
130130
password: string,
131-
token = '',
132131
hub_url = '',
133-
clusterFsid = '',
134-
prometheusApiUrl = '',
135132
ssl = false,
136133
cert = '',
137134
ttl: number
@@ -141,10 +138,7 @@ export class MultiClusterService {
141138
cluster_alias: clusterAlias,
142139
username,
143140
password,
144-
token,
145141
hub_url,
146-
cluster_fsid: clusterFsid,
147-
prometheus_api_url: prometheusApiUrl,
148142
ssl_verify: ssl,
149143
ssl_certificate: cert,
150144
ttl: ttl
@@ -155,7 +149,6 @@ export class MultiClusterService {
155149
url: any,
156150
username: string,
157151
password: string,
158-
token = '',
159152
ssl = false,
160153
cert = '',
161154
ttl: number
@@ -164,7 +157,6 @@ export class MultiClusterService {
164157
url,
165158
username,
166159
password,
167-
token,
168160
ssl_verify: ssl,
169161
ssl_certificate: cert,
170162
ttl: ttl

0 commit comments

Comments
 (0)