generate password feature for kratos admin creation

This commit is contained in:
sharan
2022-12-01 17:39:13 +05:30
parent 4390d1cea5
commit 7bf4b66369
6 changed files with 39 additions and 17 deletions
+3 -3
View File
@@ -20,6 +20,7 @@ import (
"github.com/paralus/paralus/pkg/common"
"github.com/paralus/paralus/pkg/enforcer"
"github.com/paralus/paralus/pkg/service"
"github.com/paralus/paralus/pkg/utils"
commonv3 "github.com/paralus/paralus/proto/types/commonpb/v3"
rolev3 "github.com/paralus/paralus/proto/types/rolepb/v3"
systemv3 "github.com/paralus/paralus/proto/types/systempb/v3"
@@ -299,11 +300,12 @@ func main() {
retry:
numOfRetries := 0
// should we directly interact with kratos and create a user with a password?
orgA, err := us.Create(context.Background(), &userv3.User{
_, err = us.Create(context.Background(), &userv3.User{
Metadata: &commonv3.Metadata{Name: *oae, Partner: *partner, Organization: *org},
Spec: &userv3.UserSpec{
FirstName: *oafn,
LastName: *oaln,
Password: utils.GetRandomPassword(8),
Groups: []string{admingrp.Metadata.Name, localUsersGrp.Metadata.Name},
ProjectNamespaceRoles: []*userv3.ProjectNamespaceRole{{Role: "ADMIN", Group: &admingrp.Metadata.Name}}},
})
@@ -318,6 +320,4 @@ retry:
time.Sleep(10 * time.Second)
goto retry
}
fmt.Println("Org Admin signup URL: ", *orgA.Spec.RecoveryUrl)
}