You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2020/06/28 11:55:05 UTC

[GitHub] [servicecomb-service-center] tianxiaoliang commented on a change in pull request #652: able to change password

tianxiaoliang commented on a change in pull request #652:
URL: https://github.com/apache/servicecomb-service-center/pull/652#discussion_r446641160



##########
File path: server/service/rbac/rbac.go
##########
@@ -49,43 +55,52 @@ func Init() {
 	if err != nil {
 		log.Fatal("can not enable auth module", err)
 	}
-	admin := archaius.GetString(InitRoot, "")
-	if admin == "" {
-		log.Fatal("can not enable rbac, root is empty", nil)
-		return
-	}
-	accountExist, err := dao.AccountExist(context.Background(), admin)
+	accountExist, err := dao.AccountExist(context.Background(), RootName)
 	if err != nil {
 		log.Fatal("can not enable auth module", err)
 	}
 	if !accountExist {
-		initFirstTime(admin)
+		initFirstTime(RootName)
 	}
-	overrideSecretKey()
+	readPrivateKey()
 	readPublicKey()
 	log.Info("rbac is enabled")
 }
 
+//readPublicKey read key to memory
+func readPrivateKey() {
+	pf := beego.AppConfig.String("rbac_rsa_private_key_file")
+	// 打开文件
+	data, err := ioutil.ReadFile(pf)
+	if err != nil {
+		log.Fatal("can not read private key", err)
+		return
+	}
+	archaius.Set("rbac_private_key", string(data))
+	log.Info("read private key success %s")
+}
+
 //readPublicKey read key to memory
 func readPublicKey() {
-	pf := beego.AppConfig.String("rbac_rsa_pub_key_file")
+	pf := beego.AppConfig.String("rbac_rsa_public_key_file")
 	// 打开文件
-	fp, err := os.Open(pf)
+	f, err := os.Open(pf)
 	if err != nil {
 		log.Fatal("can not find public key", err)
 		return
 	}
-	defer fp.Close()
+	defer f.Close()
 	buf := make([]byte, 1024)
 	for {
 		// 循环读取文件
-		_, err := fp.Read(buf)
+		_, err := f.Read(buf)

Review comment:
       这个理由是?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org