secretkey
在执行./prepare命令时,会在/data目录下生成一个secretkey文件,里面是16个字符。
该字符串的作用是给target的password加密(从harbor源码获知,ui/config/config.go文件代码)
// SecretKey returns the secret key to encrypt the password of target
func SecretKey() string {
return uiConfig.Config["secret_key"].(string)
}
secretkey文件由prepare脚本生成(如果文件已存在,则读取内容;否则随机生成一个16长度的字符串,然后保存存在$path/secretkey
文件中):
prepare
def get_secret_key(path):
key_file = os.path.join(path, "secretkey")
if os.path.isfile(key_file):
with open(key_file, 'r') as f:
key = f.read()
print("loaded secret key")
if len(key) != 16:
raise Exception("secret key's length has to be 16 chars, current length: %d" % len(key))
return key
if not os.path.isdir(path):
os.makedirs(path, mode=0600)
key = ''.join(random.choice(string.ascii_letters+string.digits) for i in range(16))
with open(key_file, 'w') as f:
f.write(key)
print("generated and saved secret key")
return key
$path
变量则为从参数data-volume
得到(prepare文件代码):
secret_key = get_secret_key(args.data_volume)
而data-volume
则默认为/data/
(prepare文件代码):
parser.add_argument('--data-volume', dest='data_volume', default='/data/',type=str,help="the path of Harbor data volume, which is set in template of docker-compose.")
Last updated
Was this helpful?