Skip to content

Commit

Permalink
web: use restricted-access user joining nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
BeryJu committed Feb 11, 2025
1 parent 75526bf commit 67d6ea0
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions web/src/pages/cluster/wizard/ClusterJoinInitial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import "../../../elements/forms/HorizontalFormElement";
import { WizardFormPage } from "../../../elements/wizard/WizardFormPage";
import { Roles } from "../RolesPage";

export const joinUserUsername = "gravity-system:cluster:join";

@customElement("gravity-cluster-join-initial")
export class ClusterJoinInitial extends WizardFormPage {
sidebarLabel = () => "Node details";
Expand All @@ -33,10 +35,21 @@ export class ClusterJoinInitial extends WizardFormPage {
const info = await new ClusterInstancesApi(DEFAULT_CONFIG).clusterGetInstanceInfo();
this.host.state["node_ip"] = info.instanceIP;

const user = await new RolesApiApi(DEFAULT_CONFIG).apiUsersMe();
await new RolesApiApi(DEFAULT_CONFIG).apiPutUsers({
username: joinUserUsername,
authAPIUsersPutInput: {
password: "",
permissions: [
{
methods: ["POST"],
path: "/api/v1/etcd/join",
},
],
},
});

const token = await new RolesApiApi(DEFAULT_CONFIG).apiPutTokens({
username: user.username,
username: joinUserUsername,
});
this.host.state["join_token"] = token.key;
return true;
Expand Down

0 comments on commit 67d6ea0

Please sign in to comment.